--- loncom/interface/lonrequestcourse.pm 2015/03/26 14:16:11 1.86 +++ loncom/interface/lonrequestcourse.pm 2015/06/09 21:22:57 1.89 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.86 2015/03/26 14:16:11 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.89 2015/06/09 21:22:57 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -768,7 +768,7 @@ END "; } } - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( official => 'You are not permitted to request creation of an official course in this domain.', 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.', @@ -776,33 +776,34 @@ END all => 'You must choose a specific course type when making a new course request.', allt => '"All types" is not allowed.', ); + &js_escape(\%js_lt); $js .= <<END; if (crschoice == 'official') { if (official != 1) { - alert("$lt{'official'}"); + alert("$js_lt{'official'}"); return false; } } else { if (crschoice == 'unofficial') { if (unofficial != 1) { - alert("$lt{'unofficial'}"); + alert("$js_lt{'unofficial'}"); return false; } } else { if (crschoice == 'community') { if (community != 1) { - alert("$lt{'community'}"); + alert("$js_lt{'community'}"); return false; } } else { if (crschoice == 'textbook') { if (textbook != 1) { - alert("$lt{'community'}"); + alert("$js_lt{'textbook'}"); return false; } } else { if (actionchoice == 'new') { - alert('$lt{'all'}'+'\\n'+'$lt{'allt'}'); + alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); return false; } } @@ -939,7 +940,8 @@ END if ($action eq 'new') { my $jsextra; if (($state eq 'courseinfo') || ($state eq 'codepick')) { - $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); + $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom,'','','','','', + $newinstcode); } elsif ($state eq 'enrollment') { if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) { @@ -1174,6 +1176,8 @@ sub enrollment_lcsec_js { my %alerts = §ion_check_alerts(); my $secname = $alerts{'badsec'}; my $secnone = $alerts{'reserved'}; + &js_escape(\$secname); + &js_escape(\$secnone); my $output = ' function validateEnrollSections(formname,nextstate) { var badsectotal = 0; @@ -1231,8 +1235,10 @@ function validateEnrollSections(formname sub personnel_lcsec_js { my %alerts = §ion_check_alerts(); - my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'}; + my $secname = $alerts{'badsec'}."\n".$alerts{'separate'}; my $secnone = $alerts{'reserved'}; + &js_escape(\$secname); + &js_escape(\$secnone); my $output = ' function validatePersonnelSections(formname,nextstate) { var badsectotal = 0; @@ -2415,8 +2421,9 @@ ENDJS } sub viewcancel_javascript { - my $alert = &mt('Are you sure you want to cancel this request?').'\\n'. + my $alert = &mt('Are you sure you want to cancel this request?')."\n". &mt('Your request will be removed.'); + &js_escape(\$alert); return << "ENDJS"; function nextPage(formname,nextstate) { if (confirm('$alert')) { @@ -2788,6 +2795,7 @@ sub print_review { my $enrollrow_title = &mt('Default Access Dates').'<br />'. '('.&Apache::lonnet::plaintext('st',$category).')'; + my $instcode; if ($env{'form.crstype'} eq 'official') { if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) { foreach my $title (@{$codetitles}) { @@ -2803,6 +2811,11 @@ sub print_review { } } } + if (ref($code_order) eq 'ARRAY') { + foreach my $item (@{$code_order}) { + $instcode .= $env{'form.instcode_'.$item}; + } + } $inst_headers .= '<th>'.&mt('Credits').'</th>'; if ($instcredits) { $inst_values .= '<td>'.$instcredits.'</td>'; @@ -2890,7 +2903,7 @@ sub print_review { ($env{'form.clonedom'} =~ /^$match_domain$/)) { my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname, $udom,$env{'form.clonecrs'},$env{'form.clonedom'}, - $env{'form.crstype'}); + $env{'form.crstype'},$dom,$instcode); if ($canclone) { my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, $env{'form.clonecrs'},('description','internal.coursecode')); @@ -3052,19 +3065,20 @@ sub dates_from_form { sub courseinfo_form { my ($dom,$formname,$crstype,$next,$description) = @_; - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( official => 'You must provide a (brief) course description.', community => 'You must provide a (brief) community description.' ); - $lt{'unofficial'} = $lt{'official'}; - $lt{'textbook'} = $lt{'official'}; + &js_escape(\%js_lt); + $js_lt{'unofficial'} = $js_lt{'official'}; + $js_lt{'textbook'} = $js_lt{'official'}; my $js_validate = <<"ENDJS"; <script type="text/javascript"> // <![CDATA[' function validateForm() { if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) { - alert('$lt{$crstype}'); + alert('$js_lt{$crstype}'); return; } nextPage(document.$formname,'$next'); @@ -3588,7 +3602,7 @@ sub print_request_outcome { my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'}, - $crstype); + $crstype,$dom,$instcode); if ($canclone) { $clonecrs = $env{'form.clonecrs'}; $clonedom = $env{'form.clonedom'}; @@ -4462,7 +4476,7 @@ sub print_textbook_form { my ($clonedom,$clonecrs) = split(/_/,$item); if (ref($prefab{$type}{$item}) eq 'HASH') { if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, - $env{'user.domain'},$clonecrs,$clonedom,$crstype)) { + $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom)) { my $num = $prefab{$type}{$item}{'order'}; $ordered{$type}{$num} = $item; @@ -4804,7 +4818,7 @@ sub process_textbook_request { if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') { my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, - $env{'user.domain'},$clonecrs,$clonedom,$crstype); + $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom); unless ($canclone) { undef($clonecrs); undef($clonedom); @@ -4874,13 +4888,14 @@ sub textbook_request_javascript { my ($numprefab,$numcurrent) = @_; return unless (ref($numprefab) eq 'HASH'); return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent); - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( choose => 'Please select a content option.', textbook => 'Please select a textbook, or choose a different option.', template => 'Please select a template, or choose a different option.', existing => 'Please select one of your existing courses to copy, or choose a different option.', title => 'Please enter a course title.', ); + &js_escape(\%js_lt); return <<"ENDSCRIPT"; function cloneChoice() { if (document.requestcourse.cloning) { @@ -4943,9 +4958,9 @@ function uncheckAllRadio() { if (numbook > 0) { uncheckRadio('textbook'); } - if (nutemplate > 0) { + if (numtemplate > 0) { uncheckRadio('template'); - }m + } if (numcurrent > 0) { uncheckRadio('existing'); } @@ -4958,7 +4973,7 @@ function validTextbookReq() { var radioLength = document.requestcourse.cloning.length; if (radioLength == undefined) { if (document.requestcourse.cloning.checked == false) { - alert("$lt{'choose'}"); + alert("$js_lt{'choose'}"); return false; } else { cloneChoice = document.requestcourse.cloning.value; @@ -4971,7 +4986,7 @@ function validTextbookReq() { } } if (cloneChoice == 0) { - alert("$lt{'choose'}"); + alert("$js_lt{'choose'}"); return false; } } @@ -5003,12 +5018,12 @@ function validTextbookReq() { } if (chosen == 0) { if (cloneChoice == 'textbook') { - alert("$lt{'textbook'}"); + alert("$js_lt{'textbook'}"); } else { if (cloneChoice == 'template') { - alert("$lt{'template'}"); + alert("$js_lt{'template'}"); } else { - alert("$lt{'existing'}"); + alert("$js_lt{'existing'}"); } } return false; @@ -5016,7 +5031,7 @@ function validTextbookReq() { } } if (document.requestcourse.cdescr.value == '') { - alert("$lt{'title'}"); + alert("$js_lt{'title'}"); return false; } return true;