--- loncom/interface/lonrequestcourse.pm 2015/06/14 00:02:43 1.90 +++ loncom/interface/lonrequestcourse.pm 2016/04/02 04:30:21 1.96 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.90 2015/06/14 00:02:43 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.96 2016/04/02 04:30:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -760,6 +760,7 @@ function check_can_request(crschoice,act var unofficial = ''; var community = ''; var textbook = ''; + var placement = ''; END if (ref($can_request) eq 'HASH') { foreach my $item (keys(%{$can_request})) { @@ -773,6 +774,7 @@ END unofficial => 'You are not permitted to request creation of an unofficial course in this domain.', community => 'You are not permitted to request creation of a community in this domain.', textbook => 'You are not permitted to request creation of a textbook course in this domain', + placement => 'You are not permitted to request creation of a placement test in this domain', all => 'You must choose a specific course type when making a new course request.', allt => '"All types" is not allowed.', ); @@ -802,9 +804,16 @@ END return false; } } else { - if (actionchoice == 'new') { - alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); - return false; + if (crschoice == 'placement') { + if (placement != 1) { + alert("$js_lt{'placement'}"); + return false; + } + } else { + if (actionchoice == 'new') { + alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); + return false; + } } } } @@ -815,7 +824,7 @@ END END my ($pagetitle,$pageinfo,$domaintitle,$earlyout); if (ref($can_request) eq 'HASH') { - if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || $can_request->{'textbook'}) { + if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || ($can_request->{'textbook'}) || ($can_request->{'placement'})) { if ($can_request->{'community'}) { $pagetitle = 'Course/Community Requests'; $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.'); @@ -992,6 +1001,8 @@ END $title = &mt('Pending requests for unofficial courses'); } elsif ($env{'form.crstype'} eq 'textbook') { $title = &mt('Pending requests for textbook courses'); + } elsif ($env{'form.crstype'} eq 'textbook') { + $title = &mt('Pending requests for placement tests'); } else { $title = &mt('Pending course/community requests'); } @@ -2093,7 +2104,8 @@ sub print_personnel_menu { official => 'Requestor is automatically assigned Course Coordinator role.', ); $lt{'unofficial'} = $lt{'official'}; - $lt{'textbook'} = $lt{'textbook'}; + $lt{'textbook'} = $lt{'official'}; + $lt{'placement'} = $lt{'official'}; $output .= &Apache::lonhtmlcommon::row_headline(). '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>'; } @@ -2504,7 +2516,7 @@ sub print_request_logs { if (ref($domconfig{'requestcourses'}) eq 'HASH') { if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') { if ($curr{'crstype'} eq 'any') { - my @types = qw(official unofficial community textbook); + my @types = qw(official unofficial community textbook placement); foreach my $type (@types) { if ($domconfig{'requestcourses'}{'uniquecode'}{$type}) { $showuniquecode = 1; @@ -2672,7 +2684,7 @@ sub reqstatus_names { rejected => 'Request rejected', cancelled => 'Request cancelled', ); - if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) { + if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook') || ($crstype eq 'placement')) { $statusnames{'created'} = &mt('Course created'); } elsif ($crstype eq 'community') { $statusnames{'created'} = &mt('Community created'); @@ -3076,6 +3088,7 @@ sub courseinfo_form { &js_escape(\%js_lt); $js_lt{'unofficial'} = $js_lt{'official'}; $js_lt{'textbook'} = $js_lt{'official'}; + $js_lt{'placement'} = $js_lt{'official'}; my $js_validate = <<"ENDJS"; <script type="text/javascript"> // <![CDATA[' @@ -3644,7 +3657,7 @@ sub print_request_outcome { $instcode,$req_notifylist,\@instsections,\%domconfig); return ($result,$output,$customized); } - + sub process_request { my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections, $domconfig) = @_; @@ -3662,12 +3675,14 @@ sub process_request { $output = &mt('You are not permitted to request creation of communities'); } elsif ($crstype eq 'textbook') { $output = &mt('You are not permitted to request creation of textbook courses'); + } elsif ($crstype eq 'placement') { + $output = &mt('You are not permitted to request creation of placement tests'); } else { $output = &mt('Unrecognized course type: [_1]',$crstype); } $storeresult = 'notpermitted'; } else { - my ($disposition,$message,$reqstatus,$coursedesc,%customvalidation); + my ($disposition,$message,$reqstatus,$coursedesc,$accessstart,$accessend,%customvalidation); my %reqhash = ( reqtime => $now, crstype => $crstype, @@ -3679,6 +3694,8 @@ sub process_request { $env{'user.domain'}); if (ref($details) eq 'HASH') { $coursedesc = $details->{'cdescr'}; + $accessstart = $details->{'accessstart'}; + $accessend = $details->{'accessend'}; } if ($val eq 'autolimit=') { $disposition = 'process'; @@ -3730,7 +3747,7 @@ sub process_request { } $reqhash{'disposition'} = $disposition; $reqstatus = $disposition; - my ($modified,$queued,$coursedesc,$token,%customitems); + my ($modified,$queued,$token,%customitems); unless ($disposition eq 'rejected') { my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'}, $env{'user.domain'},$fullname,$coursedesc,undef, @@ -3786,6 +3803,9 @@ sub process_request { $customitems{'_LC_owneremail'} = $owneremail; } $customitems{'_LC_coursedomainname'} = &Apache::lonnet::domain($dom,'description'); + $customitems{'_LC_coursedescription'} = $coursedesc; + $customitems{'_LC_coursestartdate'} = $accessstart; + $customitems{'_LC_courseenddate'} = $accessend; my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum, 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult, \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles, @@ -4294,7 +4314,7 @@ sub check_autolimit { if (($crstype eq 'community') && (exists($crsroles{$cnum.':'.$cdom.':co'}))) { $count ++; - } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) && + } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook') || ($crstype eq 'placement')) && (exists($crsroles{$cnum.':'.$cdom.':cc'}))) { $count ++; } @@ -4549,7 +4569,16 @@ sub print_textbook_form { $cc_clone .= $cdom.':'.$cnum.'&'; unless (exists($cloneable{$cdom.'_'.$cnum})) { my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1}); - $cloneable{$cdom.'_'.$cnum} = \%courseinfo; + $cloneable{$cdom.'_'.$cnum} = { + context => $courseinfo{'internal.creationcontext'}, + created => $courseinfo{'internal.created'}, + creator => $courseinfo{'internal.creator'}, + description => $courseinfo{'description'}, + inst_code => $courseinfo{'coursecode'}, + owner => $courseinfo{'internal.courseowner'}, + releaserequired => $courseinfo{'internal.releaserequired'}, + type => $courseinfo{'type'}, + }; } } @@ -4742,13 +4771,13 @@ sub print_textbook_form { if (keys(%cloneable)) { $r->print('<div id="showexisting" style="display:none">'. &clone_selection_table($dom,'owned',\%cloneable). - '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. + '<p><input type="radio" name="owndatemode" value="delete" /> '.$lt{'ncd'}. '</label><br /><label>'. - '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}. + '<input type="radio" name="owndatemode" value="preserve" /> '.$lt{'prd'}. '</label><br /><label>'. - '<input type="radio" name="datemode" value="shift" checked="checked" /> '. + '<input type="radio" name="owndatemode" value="shift" checked="checked" /> '. $lt{'shd'}.'</label>'. - '<input type="text" size="5" name="dateshift" value="365" />'. + '<input type="text" size="5" name="owndateshift" value="365" />'. '</div>'); } # @@ -4757,13 +4786,13 @@ sub print_textbook_form { if (keys(%domcloneable)) { $r->print('<div id="showcolleague" style="display:none">'. &clone_selection_table($dom,'colleague',\%domcloneable). - '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. + '<p><input type="radio" name="colldatemode" value="delete" /> '.$lt{'ncd'}. '</label><br /><label>'. - '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}. + '<input type="radio" name="colldatemode" value="preserve" /> '.$lt{'prd'}. '</label><br /><label>'. - '<input type="radio" name="datemode" value="shift" checked="checked" /> '. + '<input type="radio" name="colldatemode" value="shift" checked="checked" /> '. $lt{'shd'}.'</label>'. - '<input type="text" size="5" name="dateshift" value="365" />'. + '<input type="text" size="5" name="colldateshift" value="365" />'. '</div>'); } @@ -4845,11 +4874,14 @@ sub clone_selection_table { $cleantitle=~s/'/\\'/g; $cleantitle =~ s/^\s+//; my ($namestr,@owners,%ownernames); - my $singleowner = $cloneableref->{$cid}{'internal.courseowner'}; - push(@owners,$singleowner); + if ($cloneableref->{$cid}{'owner'} ne '') { + push(@owners,$cloneableref->{$cid}{'owner'}); + } if ($cloneableref->{$cid}{'co-owners'} ne '') { - foreach my $item (split(/,/,$cloneableref->{$cid}{'internal.co-owners'})) { - push(@owners,$item); + foreach my $item (split(/,/,$cloneableref->{$cid}{'co-owners'})) { + if (($item ne '') && (!grep(/^\Q$item\E$/,@owners))) { + push(@owners,$item); + } } } foreach my $owner (@owners) { @@ -4983,9 +5015,28 @@ sub process_textbook_request { accessend => $accessend, personnel => {}, }; - if ($reqtype eq 'existing') { - $details->{datemode} = $env{'form.datemode'}; - $details->{dateshift} = $env{'form.dateshift'}; + if (($clonecrs ne '') && ($clonedom ne '')) { + if ($reqtype eq 'existing') { + $details->{datemode} = $env{'form.owndatemode'}; + if ($details->{datemode} eq 'shift') { + $details->{dateshift} = $env{'form.owndateshift'}; + } else { + $details->{dateshift} = ''; + } + } elsif ($reqtype eq 'colleague') { + $details->{datemode} = $env{'form.colldatemode'}; + if ($details->{datemode} eq 'shift') { + $details->{dateshift} = $env{'form.colldateshift'}; + } else { + $details->{dateshift} = ''; + } + } + if ($details->{dateshift} ne '') { + $details->{dateshift} =~ s/[^\d\.]+//g; + } + } else { + $details->{datemode} = ''; + $details->{dateshift} = ''; } my $lonhost = $r->dir_config('lonHostID'); $r->rflush(); @@ -5159,7 +5210,7 @@ function validTextbookReq() { if (cloneChoice == 'existing') { alert("$js_lt{'existing'}"); } else { - alert("js_$lt{'colleague'}"); + alert("$js_lt{'colleague'}"); } } }