--- loncom/interface/loncreatecourse.pm 2014/01/29 18:37:41 1.154 +++ loncom/interface/loncreatecourse.pm 2016/04/04 01:09:48 1.159 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.154 2014/01/29 18:37:41 bisitz Exp $ +# $Id: loncreatecourse.pm,v 1.159 2016/04/04 01:09:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -91,6 +91,8 @@ sub print_course_creation_page { my $crstype = 'Community'; if ($env{'form.phase'} eq 'courseone') { $crstype = 'Course'; + } elsif ($env{'form.phase'} eq 'placementone') { + $crstype = 'Placement'; } my $defdom=$env{'request.role.domain'}; my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom); @@ -130,9 +132,28 @@ sub print_course_creation_page { $krbform = &Apache::loncommon::authform_kerberos(%param); $intform = &Apache::loncommon::authform_internal(%param); $locform = &Apache::loncommon::authform_local(%param); - } else { + } elsif ($crstype eq 'Community') { my $title_alert = &mt('A Community title is required'); my $coord_alert = &mt('The username of the Coordinator is required'); + &js_escape(\$title_alert); + &js_escape(\$coord_alert); + $javascript_validations = qq| +function validate(formname) { + if (formname.title == '') { + alert("$title_alert"); + return; + } + if (formname.ccuname == '') { + alert("$coord_alert"); + } + formname.submit(); +} + |; + } else { + my $title_alert = &mt('A Placement Test title is required'); + my $coord_alert = &mt('The username of the Course Coordinator is required'); + &js_escape(\$title_alert); + &js_escape(\$coord_alert); $javascript_validations = qq| function validate(formname) { if (formname.title == '') { @@ -145,6 +166,7 @@ function validate(formname) { formname.submit(); } |; + } my %lt=&Apache::lonlocal::texthash( 'cinf' => "Course Information", @@ -158,7 +180,7 @@ function validate(formname) { 'snid' => "Section Numbers and corresponding LON-CAPA section IDs", 'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2", 'crcs' => "Crosslisted courses", - 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) sectionID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2", + 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) section ID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2", 'ccre' => "Course credits", 'crcd' => "Create six character course identifier to share with students", 'cred' => "the number of institutional credits students will earn by completing this course", @@ -242,6 +264,18 @@ function validate(formname) { $lt{'cc'} = &mt('(will be assigned Coordinator role)'); $lt{'cgrs'} = &mt('Community Group Settings'); $lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files'); + } elsif ($crstype eq 'Placement') { + $lt{'cinf'} = &mt('Placement Test Information'); + $lt{'ctit'} = &mt('Placement Test Title'); + $lt{'chsr'} = &mt('Placement Test Home Server'); + $lt{'cidn'} = &mt('Placement Test ID/Number'); + $lt{'crco'} = &mt('Placement Test Content'); + $lt{'cncr'} = &mt('Completely new placement test'); + $lt{'cecr'} = &mt('Clone an existing placement test'); + $lt{'sacr'} = &mt('Do NOT generate as standard placement test'); + $lt{'stco'} = &mt('standard placement tests only'); + $lt{'navi'} = &mt('Placement Test Contents'); + $lt{'cid'} = &mt('Placement Test ID'); } my $js = <<END; <script type="text/javascript"> @@ -270,6 +304,7 @@ END my %titles = &Apache::lonlocal::texthash( courseone => 'Create a New Course', groupone => 'Create a New Community', + placementone=> 'Create a New Placement Test', ); my $start_page = &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js); @@ -349,7 +384,11 @@ END .'<input type="radio" name="uniquecode" value="1" />'.&mt('Yes').(' 'x2) .'<input type="radio" name="uniquecode" value="0" checked="checked" />'.&mt('No') .&Apache::lonhtmlcommon::row_closure() - ); + ); + } + my $blankchk; + if ($crstype eq 'Placement') { + $blankchk = ' checked="checked"'; } # Table: New Course / Clone Course $r->print(&Apache::lonhtmlcommon::row_headline() @@ -375,15 +414,14 @@ END .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title($lt{'fres'}) .'<label>' - .'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'} - .'</label>' - .' '); + .'<input type="radio" name="firstres" value="blank"'.$blankchk.' />'.$lt{'blnk'} + .'</label>'); if ($crstype eq 'Community') { - $r->print('<label>' + $r->print(' <label>' .'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'} .'</label>'); - } else { - $r->print('<label>' + } elsif ($crstype eq 'Course') { + $r->print(' <label>' .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'} .'</label>' .' ' @@ -565,6 +603,14 @@ END <input type="submit" value="'.$lt{'opcm'}.'" /> </p>' ); + } elsif ($crstype eq 'Placement') { + $r->print(' +<p> +<input type="hidden" name="prevphase" value="placementone" /> +<input type="hidden" name="phase" value="placementtwo" /> +<input type="submit" value="'.$lt{'opcm'}.'" /> +</p>' + ); } $r->print('</form>'. $end_page); @@ -585,6 +631,8 @@ sub create_course { $crstype='Course'; $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll'); $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll'); + } elsif ($env{'form.phase'} eq 'placementtwo') { + $crstype='Placement'; } $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess'); $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess'); @@ -732,9 +780,9 @@ sub create_course { } sub print_intro_page { - my ($r,$show_all_choices) = @_; + my ($r,$show_all_choices,$cancreate) = @_; my $start_page = - &Apache::loncommon::start_page('Create a New Course or Community'); + &Apache::loncommon::start_page('Create a New Course, Community or Placement Test'); my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses'); my $end_page = &Apache::loncommon::end_page(); @@ -756,18 +804,26 @@ sub print_intro_page { { linktext => 'Create a single community', url => '/adm/createcourse?phase=groupone', - permission => $show_all_choices, + permission => $cancreate->{'Community'}, #help => '', icon => 'crsnew.png', linktitle => 'Create a new collaborative community by completing an online form.' }, { - linktext => 'Create courses/communities by uploading an attributes file', + linktext => 'Create a single placement test', + url => '/adm/createcourse?phase=placementone', + permission => $cancreate->{'Placement'}, + #help => '', + icon => 'crsnew.png', + linktitle => 'Create a new placement test by completing an online form.' + }, + { + linktext => 'Create courses/communities/placement tests by uploading an attributes file', url => '/adm/createcourse?phase=batchone', permission => 1, help => 'Batch_Creation', icon => 'uplcrs.png', - linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.' + linktitle => 'Upload an attributes file containing specifications for one or more courses, communities or placement tests in XML format.' }, ] }, @@ -779,7 +835,7 @@ sub print_intro_page { permission => $show_all_choices, #help => '', icon => 'rcrs.png', - linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.' + linktitle => 'Display course, community creation and placement test requests submitted by authorized users, held pending approval by a Domain Coordinator.' }, { linktext => 'View pending official course requests', @@ -800,7 +856,7 @@ sub print_intro_page { permission => $show_all_choices, #help => '', icon => 'document-properties.png', - linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.' + linktitle => 'Display information about when, how and by whom courses, communities and placement tests were created in this domain.' }, ] }, @@ -817,18 +873,18 @@ sub print_intro_page { sub upload_batchfile { my $r = shift; my $start_page = - &Apache::loncommon::start_page('Create a New Course or Community'); - my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses'); + &Apache::loncommon::start_page('Create a New Course, Community, or Placement Test'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community/Placement Test Attributes File','Create_Course',undef,'Create_Courses'); my $end_page = &Apache::loncommon::end_page(); $r->print($start_page.$crumbs); - $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>'); + $r->print('<h3>'.&mt('Upload a courses, communities or placement tests attributes file').'</h3>'); $r->print('<form name="batchcreate" method="post" '. 'enctype="multipart/form-data" action="/adm/createcourse">'. '<input type="file" name="coursecreatorxml" />'. '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'. '<input type="submit" name="batchsubmit" '. - 'value="'.&mt('Create Courses/Communities').'" /></form>'); + 'value="'.&mt('Create Courses/Communities/Placement Tests').'" /></form>'); $r->print($end_page); return; } @@ -836,7 +892,7 @@ sub upload_batchfile { sub process_batchfile { my $r = shift; my $start_page = - &Apache::loncommon::start_page('Create a New Course or Community'); + &Apache::loncommon::start_page('Create a New Course, Community or Placement Test'); my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'); my $end_page = &Apache::loncommon::end_page(); @@ -955,6 +1011,8 @@ sub print_creation_logs { $crstype = '.'; } elsif ($curr{'type'} eq 'community') { $crstype = 'Community'; + } elsif ($curr{'type'} eq 'placement') { + $crstype = 'Placement'; } my ($instcodefilter,$regexpok); @@ -1045,6 +1103,8 @@ sub print_creation_logs { my $showtype; if ($courses{$cid}{type} eq 'Community') { $showtype = &mt('community'); + } elsif ($courses{$cid}{type} eq 'Placement') { + $showtype = &mt('placement test'); } else { my $instcode = $courses{$cid}{inst_code}; if ($instcode ne '') { @@ -1158,7 +1218,7 @@ sub creation_display_filter { $typename = $typenames->{$type}; } } - $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n"; + $output .= '<option value="'.$type.'"'.$selstr.'>'.&mt($typename).'</option>'."\n"; } $output .= '</select></td>'; } @@ -1257,10 +1317,25 @@ sub handler { my $show_all_choices = 0; my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'}); + my %cancreate = ( + Community => 0, + Placement => 0, + ); + if (($primary_rev ne 'refused') && ($primary_rev ne 'error') && ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) { $show_all_choices = 1; + my ($primary_major,$primary_minor) = split(/\./,$primary_rev); + foreach my $key (keys(%cancreate)) { + my ($needsmajor,$needsminor) = + split(/\./,$Apache::lonnet::needsrelease{'course:crstype:'.$key}); + unless (($needsmajor > $primary_major) || + (($needsmajor == $primary_major) && ($needsminor > $primary_minor))) { + $cancreate{$key} = 1; + } + } } +print STDERR "cacreate Community $cancreate{'Community'} cancreate Placement $cancreate{'Placement'}\n"; if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { &Apache::loncommon::content_type($r,'text/html'); @@ -1275,7 +1350,9 @@ sub handler { faq=>79,bug=>'Dom Coord Interface',}); if (($env{'form.phase'} eq 'coursetwo') || (($env{'form.phase'} eq 'grouptwo') && - ($show_all_choices))) { + ($cancreate{'Community'})) || + (($env{'form.phase'} eq 'placementtwo') && + ($cancreate{'Placement'}))) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}", text=>&mt('[_1] Creation Settings',), @@ -1287,7 +1364,9 @@ sub handler { &create_course($r); } elsif (($env{'form.phase'} eq 'courseone') || (($env{'form.phase'} eq 'groupone') && - ($show_all_choices))) { + ($cancreate{'Community'})) || + (($env{'form.phase'} eq 'placementone') && + ($cancreate{'Placement'}))) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/createcourse?phase=$env{'form.phase'}", text=>&mt('[_1] Creation Settings',), @@ -1316,7 +1395,7 @@ sub handler { faq=>9,bug=>'Dom Coord Interface',}); my $js = &courserequestbrowser_javascript(); my $start_page=&Apache::loncommon::start_page('Display Requests',$js); - my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Requests',undef,'Course_Requests'); $r->print($start_page.$crumbs."\n".'<div>'. &Apache::loncoursequeueadmin::display_queued_requests( 'domain',$env{'request.role.domain'}).'</div>'. @@ -1338,7 +1417,7 @@ sub handler { text=>&mt('[_1] Requests Updated',), faq=>9,bug=>'Dom Coord Interface',},); my $start_page=&Apache::loncommon::start_page('Update Requests Result'); - my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Requests',undef,'Course_Requests'); $r->print($start_page.$crumbs."\n".'<div>'. &Apache::loncoursequeueadmin::update_request_queue( 'domain',$env{'request.role.domain'}).'</div>'. @@ -1350,7 +1429,7 @@ sub handler { faq=>9,bug=>'Dom Coord Interface',}); my $js = &courserequestbrowser_javascript(); my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js); - my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Request',undef,'Course_Request'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Requests',undef,'Course_Requests'); $r->print($start_page.$crumbs."\n".'<div>'. &Apache::loncoursequeueadmin::display_queued_requests( 'pending',$env{'request.role.domain'}).'</div>'. @@ -1363,7 +1442,7 @@ sub handler { {href=>"/adm/createcourse?phase=requestvalidation", text=>&mt('Validation Attempted'),},); my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); - my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Request',undef,'Course_Request'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); $r->print($start_page.$crumbs."\n".'<div>'. &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'. &Apache::loncommon::end_page()); @@ -1382,7 +1461,7 @@ sub handler { &print_creation_logs($r); $r->print('</div>'.&Apache::loncommon::end_page()); } else { - &print_intro_page($r,$show_all_choices); + &print_intro_page($r,$show_all_choices,\%cancreate); } } else { $env{'user.error.msg'}=