--- loncom/interface/loncreatecourse.pm 2007/11/28 17:36:11 1.104.2.1 +++ loncom/interface/loncreatecourse.pm 2010/04/13 21:19:15 1.137 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.104.2.1 2007/11/28 17:36:11 albertel Exp $ +# $Id: loncreatecourse.pm,v 1.137 2010/04/13 21:19:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,6 +27,50 @@ # ### +=head1 NAME + +Apache::loncreatecourse.pm + +=head1 SYNOPSIS + +Allows domain coordinators to create new +courses and assign course coordinators. + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=item handler() + +=item print_course_creation_page() + +=item create_course() + +=item print_intro_page() + +=item upload_batchfile() + +=item process_batchfile() + +=item courserequestbrowser_javascript() + +=item print_creation_logs() + +=item creation_display_filter() + +=item context_names() + +=item instcode_srchstr() + +=item syllabuslink_javascript() + +=back + +=cut + package Apache::loncreatecourse; use strict; @@ -35,7 +79,7 @@ use Apache::lonnet; use Apache::loncommon; use Apache::londocs; use Apache::lonlocal; -use Apache::londropadd; +use Apache::lonuserutils; use Apache::lonclonecourse; use LONCAPA::batchcreatecourse; use LONCAPA; @@ -44,11 +88,10 @@ use LONCAPA; sub print_course_creation_page { my $r=shift; - my $crstype = 'Course'; -# my $crstype = 'Group'; -# if ($env{'form.phase'} eq 'courseone') { -# $crstype = 'Course'; -# } + my $crstype = 'Community'; + if ($env{'form.phase'} eq 'courseone') { + $crstype = 'Course'; + } my $defdom=$env{'request.role.domain'}; my %host_servers = &Apache::lonnet::get_servers($defdom,'library'); my $course_home = '
--
-
-
-
-
-
-
-
-
-
-
-
-
- -
--
- -
- -
+' + ); + } elsif ($crstype eq 'Community') { + $r->print('- -
- -ENDDOCUMENT + +' + ); } - $r->print($end_page); + $r->print(''. + $end_page); } # ====================================================== Phase two: make course @@ -569,7 +552,7 @@ sub create_course { my $r=shift; my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'}); my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'}); - my $crstype = 'Group'; + my $crstype = 'Community'; my ($enrollstart,$enrollend,$startaccess,$endaccess); if ($env{'form.phase'} eq 'coursetwo') { @@ -617,6 +600,8 @@ sub create_course { crsquota => $env{'form.crsquota'}, clonecourse => $env{'form.clonecourse'}, clonedomain => $env{'form.clonedomain'}, + datemode => $env{'form.datemode'}, + dateshift => $env{'form.dateshift'}, crsid => $env{'form.crsid'}, curruser => $env{'user.name'}.':'.$env{'user.domain'}, crssections => $env{'form.crssections'}, @@ -650,23 +635,26 @@ sub create_course { # Check the veracity of the course coordinator if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') { $r->print(''.&Apache::loncommon::end_page()); + $r->print(''); + my $ccrole = 'cc'; + if ($crstype eq 'Community') { + $ccrole = 'co'; + } + $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:', + ,''.$ccuname.':'.$ccdomain.'') + .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid, + $ccrole,'','','','','createcourse').'
'); } if ($env{'form.setkeys'}) { $r->print( @@ -695,36 +687,57 @@ sub create_course { $r->print('
'.&mt('Roles will be active at next login').'.
'); } $r->print(''. - &mt('Create Another [_1]',$crstype).'
'. + &mt("Create Another $crstype").''. &Apache::loncommon::end_page()); } sub print_intro_page { - my $r = shift; + my ($r,$show_all_choices) = @_; my $start_page = - &Apache::loncommon::start_page('Create a New Course'); + &Apache::loncommon::start_page('Create a New Course or Community'); my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses'); my $end_page = &Apache::loncommon::end_page(); - my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups')); - - my @choices = ({ internal_name => 'courseone', - name => &mt('Create a single course'), - short_description => - &mt('Create a new course by completing an online form.'), - }, -# { internal_name => 'groupone', -# name => &mt('Create a single collaborative group space '), -# short_description => -# &mt('Create a new group space for non-course use by completing an online form .'), -# }, - { internal_name => 'batchone', - name => &mt('Create courses/groups by uploading an attributes file'), - short_description => - &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format'), - help => 'Batch_Creation', - }, - ); + my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities')); + my @choices = ({ internal_name => 'courseone', + name => &mt('Create a single course'), + short_description => &mt('Create a new course by completing an online form.'), + }); + if ($show_all_choices) { + push(@choices,{ internal_name => 'groupone', + name => &mt('Create a single community'), + short_description => + &mt('Create a new collaborative community by completing an online form.'), + }, + { internal_name => 'batchone', + name => &mt('Create courses/communities by uploading an attributes file'), + short_description => + &mt('Upload an attributes file containing specifications for one or more courses or communities in XML format.'), + help => 'Batch_Creation', + }, + { internal_name => 'requestdisplay', + name => &mt('Approve or reject requests'), + short_description => + &mt('Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'), + }, + { internal_name => 'pendingdisplay', + name => &mt('Display official course requests'), + short_description => + &mt('Display official course requests submitted by authorized users, held pending validation of instructor status.'), + }, + { internal_name => 'creationlog', + name => &mt('View creation log'), + short_description => + &mt('Display information about when, how and by whom courses and communities were created in this domain.'), + }); + } else { + push(@choices,{ internal_name => 'batchone', + name => &mt('Create courses by uploading an attributes file'), + short_description => + &mt('Upload an attributes file containing specifications for one or more courses in XML format.'), + help => 'Batch_Creation', + }); + } my $options; foreach my $choice (@choices) { $options .='