--- loncom/interface/lonparmset.pm 2022/02/21 18:21:11 1.522.2.28.4.2
+++ loncom/interface/lonparmset.pm 2024/07/03 04:06:27 1.522.2.31
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.522.2.28.4.2 2022/02/21 18:21:11 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522.2.31 2024/07/03 04:06:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -321,6 +321,7 @@ use Apache::lonnavmaps;
use Apache::longroup;
use Apache::lonrss;
use HTML::Entities;
+use Text::Wrap();
use LONCAPA qw(:DEFAULT :match);
@@ -767,17 +768,7 @@ sub valout {
}
} else {
if ($type eq 'date_interval') {
- my ($totalsecs,$donesuffix) = split(/_/,$value,2);
- my ($usesdone,$donebuttontext,$proctor,$secretkey);
- if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
- $donebuttontext = $1;
- (undef,$proctor,$secretkey) = split(/_/,$2);
- $usesdone = 'done';
- } elsif ($donesuffix =~ /^done(|_.+)$/) {
- $donebuttontext = &mt('Done');
- ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);
- }
- my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);
+ my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
my @timer;
$year=$year-70;
$mday--;
@@ -810,13 +801,6 @@ sub valout {
push(@timer,&mt('[quant,_1,sec]',0));
}
$result.=join(", ",@timer);
- if ($usesdone eq 'done') {
- if ($secretkey) {
- $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);
- } else {
- $result .= ' + "'.$donebuttontext.'"';
- }
- }
} elsif (&isdateparm($type)) {
$result = &Apache::lonlocal::locallocaltime($value).
&date_sanity_info($value);
@@ -831,15 +815,11 @@ sub valout {
sub plink {
- my ($type,$dis,$value,$marker,$return,$call,$extra)=@_;
+ my ($type,$dis,$value,$marker,$return,$call)=@_;
my $winvalue=$value;
unless ($winvalue) {
- if ((&isdateparm($type)) || (&is_specialstring($type))) {
+ if (&isdateparm($type)) {
$winvalue=$env{'form.recent_'.$type};
- } elsif ($type eq 'string_yesno') {
- if ($env{'form.recent_string'} =~ /^(yes|no)$/i) {
- $winvalue=$env{'form.recent_string'};
- }
} else {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
@@ -850,13 +830,13 @@ sub plink {
my $valout = &valout($value,$type,1);
my $unencmarker = $marker;
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
- \$hour, \$min, \$sec, \$extra) {
+ \$hour, \$min, \$sec) {
$$item = &HTML::Entities::encode($$item,'"<>&');
$$item =~ s/\'/\\\'/g;
}
return '
';
}
@@ -872,22 +852,20 @@ sub page_js {
$pjump_def
function psub() {
- var specstring = /^string_!(yesno|any)/i;
if (document.parmform.pres_marker.value!='') {
document.parmform.action+='#'+document.parmform.pres_marker.value;
var typedef=new Array();
typedef=document.parmform.pres_type.value.split('_');
- if (document.parmform.pres_type.value!='') {
- if ((typedef[0]=='date') ||
- (specstring.test(document.parmform.pres_type.value))) {
- eval('document.parmform.recent_'+
- document.parmform.pres_type.value+
- '.value=document.parmform.pres_value.value;');
- } else {
- eval('document.parmform.recent_'+typedef[0]+
- '.value=document.parmform.pres_value.value;');
- }
+ if (document.parmform.pres_type.value!='') {
+ if (typedef[0]=='date') {
+ eval('document.parmform.recent_'+
+ document.parmform.pres_type.value+
+ '.value=document.parmform.pres_value.value;');
+ } else {
+ eval('document.parmform.recent_'+typedef[0]+
+ '.value=document.parmform.pres_value.value;');
}
+ }
document.parmform.submit();
} else {
document.parmform.pres_value.value='';
@@ -929,293 +907,6 @@ function showHide_courseContent() {
COURSECONTENTSCRIPT
}
-sub validateparms_js {
- return <<'ENDSCRIPT';
-
-function validateParms() {
- var textRegExp = /^settext_/;
- var ipRegExp = /^setip/;
- var ipallowRegExp = /^setipallow_/;
- var ipdenyRegExp = /^setipdeny_/;
- var deeplinkRegExp = /^deeplink_/;
- var dlListScopeRegExp = /^deeplink_(state|others|listing|scope)_/;
- var dlLinkProtectRegExp = /^deeplink_protect_/;
- var dlLtidRegExp = /^deeplink_ltid_/;
- var dlLticRegExp = /^deeplink_ltic_/;
- var dlKeyRegExp = /^deeplink_key_/;
- var dlMenusRegExp = /^deeplink_menus_/;
- var dlCollsRegExp = /^deeplink_colls_/;
- var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/;
- if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') {
- if (document.parmform.elements.length) {
- for (i=0; i 0) {
- var possdeeplink = document.parmform.elements[i].options[idx].value
- possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,'');
- if (document.parmform.elements['set_'+identifier].value) {
- possdeeplink = ','+possdeeplink;
- }
- document.parmform.elements['set_'+identifier].value += possdeeplink;
- }
- } else if (dlLinkProtectRegExp.test(name)) {
- if (document.parmform.elements[i].checked) {
- var identifier = name.replace(dlLinkProtectRegExp,'');
- var posslinkurl = document.parmform.elements[i].value;
- posslinkurl = posslinkurl.replace(/^\s+|\s+$/g,'');
- if (document.parmform.elements['set_'+identifier].value) {
- posslinkurl = ','+posslinkurl;
- }
- document.parmform.elements['set_'+identifier].value += posslinkurl;
- }
- } else if (dlLtidRegExp.test(name)) {
- var identifier = name.replace(dlLtidRegExp,'');
- if (isRadioSet('deeplink_protect_'+identifier,'ltid')) {
- var possltid = document.parmform.elements[i].value;
- possltid = possltid.replace(/\D+/g,'');
- if (possltid.length) {
- if (document.parmform.elements['set_'+identifier].value) {
- possltid = ':'+possltid;
- }
- document.parmform.elements['set_'+identifier].value += possltid;
- } else {
- document.parmform.elements['set_'+identifier].value = '';
- alert("A link type of 'domain LTI launch' was selected but no domain LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
- return false;
- }
- }
- } else if (dlLticRegExp.test(name)) {
- var identifier = name.replace(dlLticRegExp,'');
- if (isRadioSet('deeplink_protect_'+identifier,'ltic')) {
- var possltic = document.parmform.elements[i].value;
- possltic = possltic.replace(/\D+/g,'');
- if (possltic.length) {
- if (document.parmform.elements['set_'+identifier].value) {
- possltic = ':'+possltic;
- }
- document.parmform.elements['set_'+identifier].value += possltic;
- } else {
- document.parmform.elements['set_'+identifier].value = '';
- alert("A link type of 'course LTI launch' was selected but no course LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
- return false;
- }
- }
- } else if (dlKeyRegExp.test(name)) {
- var identifier = name.replace(dlKeyRegExp,'');
- if (isRadioSet('deeplink_protect_'+identifier,'key')) {
- var posskey = document.parmform.elements[i].value;
- posskey = posskey.replace(/^\s+|\s+$/g,'');
- var origlength = posskey.length;
- posskey = posskey.replace(/[^a-zA-Z\d_.!@#$%^&*()+=-]/g,'');
- var newlength = posskey.length;
- if (newlength > 0) {
- var change = origlength - newlength;
- if (change) {
- alert(change+' disallowed character(s) removed from deeplink key');
- }
- if (document.parmform.elements['set_'+identifier].value) {
- posskey = ':'+posskey;
- }
- document.parmform.elements['set_'+identifier].value += posskey;
- } else {
- document.parmform.elements['set_'+identifier].value = '';
- if (newlength < origlength) {
- alert("A link type of 'deep with key' was selected but the key value was blank, after removing disallowed characters.\nPlease enter a key using one or more of: a-zA-Z0-9_.!@#$%^&*()+=-");
- } else {
- alert("A link type of 'deep with key' was selected but the key value was blank.\nPlease enter a key.");
- }
- return false;
- }
- }
- } else if (dlMenusRegExp.test(name)) {
- if (document.parmform.elements[i].checked) {
- var identifier = name.replace(dlMenusRegExp,'');
- var posslinkmenu = document.parmform.elements[i].value;
- posslinkmenu = posslinkmenu.replace(/^\s+|\s+$/g,'');
- if (posslinkmenu == 'std') {
- posslinkmenu = '0';
- if (document.parmform.elements['set_'+identifier].value) {
- posslinkmenu = ','+posslinkmenu;
- }
- document.parmform.elements['set_'+identifier].value += posslinkmenu;
- }
- }
- } else if (dlCollsRegExp.test(name)) {
- var identifier = name.replace(dlCollsRegExp,'');
- if (isRadioSet('deeplink_menus_'+identifier,'colls')) {
- var posslinkmenu = document.parmform.elements[i].value;
- if (document.parmform.elements['set_'+identifier].value) {
- posslinkmenu = ','+posslinkmenu;
- }
- document.parmform.elements['set_'+identifier].value += posslinkmenu;
- }
- }
- }
- }
- }
- }
- return true;
-}
-
-function isRadioSet(name,expected) {
- var menuitems = document.getElementsByName(name);
- var radioLength = menuitems.length;
- result = false;
- if (radioLength > 1) {
- for (var j=0; j$remove ');
- });
-
- \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){
- e.preventDefault(); \$(this).closest("div").remove();
- })
-});
-
-
-END
-}
-
-sub done_proctor_js {
- return <<"END";
-function toggleSecret(form,radio,key) {
- var radios = form[radio+key];
- if (radios.length) {
- for (var i=0; i $b } (keys(%lti))) {
- if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
- $domltistr .= $item.':'.&escape(&escape($lti{$item}{'name'})).',';
- }
- }
- $domltistr =~ s/,$//;
- if ($domltistr) {
- $extra = 'ltid_'.$domltistr;
- }
- }
- my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom);
- if (keys(%courselti)) {
- foreach my $item (sort { $a <=> $b } keys(%courselti)) {
- if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) {
- $crsltistr .= $item.':'.&escape(&escape($courselti{$item}{'name'})).',';
- }
- }
- $crsltistr =~ s/,$//;
- if ($crsltistr) {
- if ($extra) {
- $extra .= '&';
- }
- $extra .= 'ltic_'.$crsltistr;
- }
- }
- if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
- my @colls;
- foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
- my ($num,$value) = split(/\%/,$item);
- if ($num =~ /^\d+$/) {
- push(@colls,$num);
- }
- }
- if (@colls) {
- if ($extra) {
- $extra .= '&';
- }
- $extra .= 'menus_'.join(',',@colls);
- }
- }
- }
if ($parmlev eq 'general') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly);
} elsif ($csec) {
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly);
} elsif ($csec) {
- &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
}
} else {
if ($uname) {
@@ -1396,32 +1039,32 @@ sub print_row {
}
}
- &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
if ($csec) {
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
}
if ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
- &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly);
}
if ($uname) {
if ($othergrp) {
$r->print($othergrp);
}
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly);
}
} # end of $parmlev if/else
@@ -1441,7 +1084,7 @@ sub print_row {
}
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly,$extra)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_;
$r->print('');
my $nolink = 0;
@@ -1469,7 +1112,7 @@ sub print_td {
} else {
$r->print(&plink($$typeoutpar[$which],
$$display{$value},$$outpar[$which],
- $mprefix."$which",'parmform.pres','psub',$extra));
+ $mprefix."$which",'parmform.pres','psub'));
}
$r->print(' '."\n");
}
@@ -1635,14 +1278,6 @@ sub isdateparm {
return (($type=~/^date/) && (!($type eq 'date_interval')));
}
-# Determine if parameter type is specialized string type (i.e.,
-# not just string or string_yesno.
-
-sub is_specialstring {
- my $type=shift;
- return (($type=~/^string_/) && ($type ne 'string_yesno'));
-}
-
#
# parmmenu displays a list of the selected parameters.
# It also offers a link to show/hide the complete parameter list
@@ -1777,7 +1412,6 @@ sub lookUpTableParameter {
'buttonshide' => 'hiding',
'turnoffeditor' => 'hiding',
'encrypturl' => 'hiding',
- 'deeplink' => 'hiding',
'randomorder' => 'high_level_randomization',
'randompick' => 'high_level_randomization',
'available' => 'slots',
@@ -1866,6 +1500,8 @@ sub parmboxes {
&whatIsMyCategory($tempparameter, \%categoryList);
}
#part to print the parm-list
+ $Text::Wrap::columns=60;
+ $Text::Wrap::separator=' ';
$r->print(''."\n");
#Print parameters
@@ -1883,8 +1519,9 @@ sub parmboxes {
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
$r->print(' checked="checked"');
}
- $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
- : $tempkey)
+ $r->print(' />'.($$allparms{$tempkey}=~/\S/ ?
+ Text::Wrap::wrap('',' 'x4,$$allparms{$tempkey})
+ : $tempkey)
.' '."\n");
}
$r->print("
\n");
@@ -2054,7 +1691,7 @@ function group_or_section(caller) {
}
if (%grouphash) {
- $groups=&mt('Group').': new();
my $tree=[];
@@ -2158,7 +1795,11 @@ sub mapmenu {
}
}
# Show it ...
- $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"'));
+ my $rowattr = ' id="mapmenu"';
+ if ($parmlev eq 'general') {
+ $rowattr .= ' style="display:none"';
+ }
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',$rowattr));
if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {
my $icon = ' ';
my $whitespace =
@@ -2569,7 +2210,7 @@ sub assessparms {
foreach my $role (@possroles) {
if (ref($sections_by_role{$role}) eq 'ARRAY') {
my @secs = sort { $a <=> $b } @{$sections_by_role{$role}};
- $csec = $secs[0];
+ $csec = $secs[0];
last;
}
}
@@ -2613,7 +2254,7 @@ sub assessparms {
$uname,$udom);
}
$message .= '';
- $uname='';
+ $uname='';
if ($env{'request.course.sec'} ne '') {
$csec=$env{'request.course.sec'};
} else {
@@ -2673,6 +2314,7 @@ sub assessparms {
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
my ($got_chostname,$chostname,$cmajor,$cminor);
my $totalstored = 0;
+ my $totalskippeduser = 0;
my $now = time;
for (my $i=0;$i<=$#markers;$i++) {
my ($needsrelease,$needsnewer,$name);
@@ -2681,6 +2323,11 @@ sub assessparms {
}
if ($markers[$i] =~ /\&(6|5|4)$/) {
next if ($noeditgrp);
+ } elsif ($markers[$i] =~ /\&(3|2|1)$/) {
+ if ($uname eq '') {
+ $totalskippeduser ++;
+ next;
+ }
}
if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) {
my (@ok_slots,@fail_slots,@del_slots);
@@ -2758,9 +2405,27 @@ sub assessparms {
# ---------------------------------------------------------------- Done storing
if ($totalstored) {
$message.=''
+ .&mt('Changes for [quant,_1,parameter] saved.',$totalstored)
+ .' '
.&mt('Changes can take up to 10 minutes before being active for all students.')
.&Apache::loncommon::help_open_topic('Caching')
.'
';
+ } else {
+ $message.=''.&mt('No parameter changes saved.').'
';
+ }
+ if ($totalskippeduser) {
+ $message .= '';
+ if ($uhome eq 'no_host') {
+ $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the username or ID was invalid.',
+ $totalskippeduser);
+ } elsif ($env{'form.userroles'} eq 'any') {
+ $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user does not have a course role.',
+ $totalskippeduser);
+ } else {
+ $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user is not a student.',
+ $totalskippeduser);
+ }
+ $message .= '
';
}
}
#----------------------------------------------- if all selected, fill in array
@@ -2771,14 +2436,11 @@ sub assessparms {
&startpage($r,$pssymb);
- foreach my $item ('tolerance','date_default','date_start','date_end',
- 'date_interval','int','float','string','string_lenient',
- 'string_examcode','string_deeplink','string_discussvote',
- 'string_useslots','string_problemstatus','string_ip',
- 'string_questiontype') {
+ foreach ('tolerance','date_default','date_start','date_end',
+ 'date_interval','int','float','string') {
$r->print(' ').
- '" name="recent_'.$item.'" />');
+ &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
+ '" name="recent_'.$_.'" />');
}
# ----- Start Parameter Selection
@@ -2815,7 +2477,7 @@ ENDPARMSELSCRIPT
$r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
&levelmenu($r,\%alllevs,$parmlev);
$r->print(&Apache::lonhtmlcommon::row_closure());
- &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
+ &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev);
$r->print(&Apache::lonhtmlcommon::row_closure());
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
&partmenu($r,\%allparts,\@psprt);
@@ -3110,7 +2772,7 @@ ENDTABLEHEADFOUR
#-------------------------------------------- for each map, gather information
my $mapid;
- foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
+ foreach $mapid (sort { $a <=> $b } keys(%maplist)) {
my $maptitle = $maplist{$mapid};
#----------------------- loop through ids and get all parameter types for map
@@ -3390,39 +3052,20 @@ sub storedata {
if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
my $cmd=$1;
my $thiskey=$2;
- next if ($cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');
my ($tuname,$tudom)=&extractuser($thiskey);
my $tkey=$thiskey;
if ($tuname) {
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
}
if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
- my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch);
+ my ($data, $typeof, $text, $name, $valchk);
if ($cmd eq 'set') {
$data=$env{$key};
- $valmatch = '';
$valchk = $data;
$typeof=$env{'form.typeof_'.$thiskey};
$text = &mt('Saved modified parameter for');
if ($typeof eq 'string_questiontype') {
$name = 'type';
- } elsif ($typeof eq 'string_deeplink') {
- ($name) = ($typeof =~ /^string_(deeplink)$/);
- my $stringmatch = &standard_string_matches($typeof);
- if (ref($stringmatch) eq 'ARRAY') {
- foreach my $item (@{$stringmatch}) {
- if (ref($item) eq 'ARRAY') {
- my ($regexpname,$pattern) = @{$item};
- if ($pattern ne '') {
- if ($data =~ /$pattern/) {
- $valmatch = $regexpname;
- $valchk = '';
- last;
- }
- }
- }
- }
- }
} elsif ($typeof eq 'string_lenient') {
$name = 'lenient';
} elsif ($typeof eq 'string_discussvote') {
@@ -3679,6 +3322,7 @@ sub listdata {
$realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' ('.$1.') ';
} elsif ($middle) {
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
+ next if (($url =~ /\.(page|sequence)$/) && ($parmlev eq 'full') && ($caller eq 'newoverview'));
$realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' ('.$url.' in '.$map.' id: '.$id.') ';
}
if ($sortorder eq 'realmstudent') {
@@ -3749,7 +3393,7 @@ sub listdata {
);
}
} elsif ($thistype eq 'date_interval') {
- $r->print(&date_interval_selector($thiskey,$name,
+ $r->print(&date_interval_selector($thiskey,
$$resourcedata{$thiskey},$readonly));
} elsif ($thistype =~ m/^string/) {
if ($name eq 'availablestudent') {
@@ -3772,66 +3416,26 @@ sub listdata {
sub date_interval_selector {
- my ($thiskey, $pname, $showval, $readonly) = @_;
- my ($result,%skipval);
+ my ($thiskey, $showval, $readonly) = @_;
+ my $result;
my $currval = $showval;
foreach my $which (['days', 86400, 31],
['hours', 3600, 23],
['minutes', 60, 59],
['seconds', 1, 59]) {
- my ($name, $factor, $max) = @{ $which };
- my $amount = int($showval/$factor);
- $showval %= $factor;
- my %select = ((map {$_ => $_} (0..$max)),
- 'select_form_order' => [0..$max]);
- $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
- \%select,'',$readonly);
- $result .= ' '.&mt($name);
- }
- if ($pname eq 'interval') {
- unless ($skipval{'done'}) {
- my $checkedon = '';
- my $checkedproc = '';
- my $currproctorkey = '';
- my $currprocdisplay = 'hidden';
- my $currdonetext = &mt('Done');
- my $checkedoff = ' checked="checked"';
- if ($currval =~ /^(?:\d+)_done$/) {
- $checkedon = ' checked="checked"';
- $checkedoff = '';
- } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
- $currdonetext = $1;
- $checkedon = ' checked="checked"';
- $checkedoff = '';
- } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
- $currproctorkey = $1;
- $checkedproc = ' checked="checked"';
- $checkedoff = '';
- $currprocdisplay = 'text';
- } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
- $currdonetext = $1;
- $currproctorkey = $2;
- $checkedproc = ' checked="checked"';
- $checkedoff = '';
- $currprocdisplay = 'text';
- }
- my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
- my $disabled;
- if ($readonly) {
- $disabled = ' disabled="disabled"';
- }
- $result .= ''.&mt('Include "done" button').
- ' '.
- &mt('No').' '.(' 'x2).
- ' '.
- &mt('Yes').' '.(' 'x2).
- ' '.
- &mt('Yes, with proctor key').' '.
- ' &').'"'.$disabled.' /> '.
- ''.&mt('Button text').': '.
- ' &').'"'.$disabled.' /> ';
- }
+ my ($name, $factor, $max) = @{ $which };
+ my $amount = int($showval/$factor);
+ $showval %= $factor;
+ my %select = ((map {$_ => $_} (0..$max)),
+ 'select_form_order' => [0..$max]);
+ if ($currval eq '') {
+ unshift(@{$select{'select_form_order'}},'');
+ $select{''} = '';
+ $amount = '';
+ }
+ $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
+ \%select,'',$readonly);
+ $result .= ' '.&mt($name);
}
unless ($readonly) {
$result .= ' ';
@@ -3843,15 +3447,20 @@ sub date_interval_selector {
sub get_date_interval_from_form {
my ($key) = @_;
my $seconds = 0;
+ my $numnotnull = 0;
foreach my $which (['days', 86400],
['hours', 3600],
['minutes', 60],
['seconds', 1]) {
- my ($name, $factor) = @{ $which };
- if (defined($env{'form.'.$name.'_'.$key})) {
- $seconds += $env{'form.'.$name.'_'.$key} * $factor;
- }
+ my ($name, $factor) = @{ $which };
+ if (defined($env{'form.'.$name.'_'.$key})) {
+ unless ($env{'form.'.$name.'_'.$key} eq '') {
+ $numnotnull ++;
+ $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+ }
+ }
}
+ return if (!$numnotnull);
return $seconds;
}
@@ -3865,277 +3474,6 @@ sub default_selector {
return ' ';
}
-sub string_ip_selector {
- my ($thiskey, $showval, $readonly) = @_;
- my %access = (
- allow => [],
- deny => [],
- );
- if ($showval ne '') {
- my @current;
- if ($showval =~ /,/) {
- @current = split(/,/,$showval);
- } else {
- @current = ($showval);
- }
- foreach my $item (@current) {
- if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) {
- push(@{$access{'deny'}},$1);
- } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) {
- push(@{$access{'allow'}},$item);
- }
- }
- }
- if (!@{$access{'allow'}}) {
- @{$access{'allow'}} = ('');
- }
- if (!@{$access{'deny'}}) {
- @{$access{'deny'}} = ('');
- }
- my ($disabled,$addmore);
- if ($readonly) {
- $disabled=' disabled="disabled"';
- } else {
- $addmore = "\n".''.&mt('Add more').' ';
- }
- my $output = '
-'.&mt('Allow from').' '.&mt('Deny from').' ';
- foreach my $acctype ('allow','deny') {
- $output .= '
-
-
-
'."\n";
- my $num = 0;
- foreach my $curr (@{$access{$acctype}}) {
- $output .= '
'."\n";
- $num ++;
- }
- $output .= '
-
'.$addmore.'
-
- ';
- }
- $output .= '
-
-
'."\n";
- return $output;
-}
-
-sub string_deeplink_selector {
- my ($thiskey, $showval, $readonly) = @_;
- my (@components,%values,@current,%titles,%options,%optiontext,%defaults,
- %selectnull,%domlti,%crslti,@possmenus);
- @components = ('state','others','listing','scope','protect','menus');
- %titles = &Apache::lonlocal::texthash (
- state => 'Access status',
- others => 'Hide other resources',
- listing => 'In Contents and/or Gradebook',
- scope => 'Access scope for link',
- protect => 'Link protection',
- menus => 'Menu Items Displayed',
- );
- %options = (
- state => ['only','off','both'],
- others => ['hide','unhide'],
- listing => ['full','absent','grades','details','datestatus'],
- scope => ['res','map','rec'],
- protect => ['none','key','ltid','ltic'],
- menus => ['std','colls'],
- );
- %optiontext = &Apache::lonlocal::texthash (
- only => 'deep only',
- off => 'deeplink off',
- both => 'regular + deep',
- hide => 'Hidden',
- unhide => 'Unhidden',
- full => 'Listed (linked) in both',
- absent => 'Not listed',
- grades => 'Listed in grades only',
- details => 'Listed (unlinked) in both',
- datestatus => 'Listed (unlinked) inc. status in both',
- res => 'resource only',
- map => 'enclosing map/folder',
- rec => 'recursive map/folder',
- none => 'not in use',
- key => 'key access',
- ltic => 'LTI access (course)',
- ltid => 'LTI access (domain)' ,
- std => 'Standard (all menus)',
- colls => 'Numbered collection',
- );
- %selectnull = &Apache::lonlocal::texthash (
- ltic => 'Select Launcher',
- ltid => 'Select Launcher',
- colls => 'Select',
- );
- if ($showval =~ /,/) {
- %values=();
- @current = split(/,/,$showval);
- ($values{'state'}) = ($current[0] =~ /^(only|off|both)$/);
- ($values{'others'}) = ($current[1] =~ /^(hide|unhide)$/);
- ($values{'listing'}) = ($current[2] =~ /^(full|absent|grades|details|datestatus)$/);
- ($values{'scope'}) = ($current[3] =~ /^(res|map|rec)$/);
- ($values{'protect'}) = ($current[4] =~ /^(key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|ltic:\d+|ltid:\d+)$/);
- ($values{'menus'}) = ($current[5] =~ /^(\d+)$/);
- } else {
- $defaults{'state'} = 'off',
- $defaults{'others'} = 'unhide',
- $defaults{'listing'} = 'full';
- $defaults{'scope'} = 'res';
- $defaults{'protect'} = 'none';
- $defaults{'menus'} = '0';
- }
- my $disabled;
- if ($readonly) {
- $disabled=' disabled="disabled"';
- }
- my %courselti =
- &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},
- $env{'course.'.$env{'request.course.id'}.'.domain'});
- foreach my $item (keys(%courselti)) {
- if (ref($courselti{$item}) eq 'HASH') {
- $crslti{$item} = $courselti{$item}{'name'};
- }
- }
- my %lti =
- &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
- 'linkprot');
- foreach my $item (keys(%lti)) {
- if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
- $domlti{$item} = $lti{$item}{'name'};
- }
- }
- if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
- foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
- my ($num,$value) = split(/\%/,$item);
- if ($num =~ /^\d+$/) {
- push(@possmenus,$num);
- }
- }
- }
-
- my $output = ' '."\n";
- return $output;
-}
-
-{
-
my %strings =
(
'string_yesno'
@@ -4163,31 +3501,8 @@ my %strings =
=> [['yes','Yes'],
['notended','Yes, unless discussion ended'],
['no','No']],
- 'string_ip'
- => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'],
- ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],
- 'string_deeplink'
- => [['on','Set choices for link protection, resource listing, access scope, and shown menu items']],
);
-my %stringmatches = (
- 'string_ip'
- => [['_allowfrom_','[^\!]+'],
- ['_denyfrom_','\!']],
- 'string_deeplink'
- => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)$']],
- );
-
-my %stringtypes = (
- type => 'string_questiontype',
- lenient => 'string_lenient',
- retrypartial => 'string_yesno',
- discussvote => 'string_discussvote',
- examcode => 'string_examcode',
- acc => 'string_ip',
- deeplink => 'string_deeplink',
- );
-
sub standard_string_options {
my ($string_type) = @_;
if (ref($strings{$string_type}) eq 'ARRAY') {
@@ -4196,14 +3511,6 @@ sub standard_string_options {
return;
}
-sub standard_string_matches {
- my ($string_type) = @_;
- if (ref($stringmatches{$string_type}) eq 'ARRAY') {
- return $stringmatches{$string_type};
- }
- return;
-}
-
sub string_selector {
my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
@@ -4234,12 +3541,6 @@ sub string_selector {
}
}
}
-
- if ($thistype eq 'string_ip') {
- return &string_ip_selector($thiskey,$showval,$readonly);
- } elsif ($thistype eq 'string_deeplink') {
- return &string_deeplink_selector($thiskey,$showval,$readonly);
- }
my ($result,$disabled);
@@ -4294,55 +3595,6 @@ sub string_selector {
return $result;
}
-sub oldversion_warning {
- my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
- my $desc;
- my %stringtypes = (
- type => 'string_questiontype',
- lenient => 'string_lenient',
- retrypartial => 'string_yesno',
- discussvote => 'string_discussvote',
- examcode => 'string_examcode',
- );
- if (exists($stringtypes{$name})) {
- if ($name eq 'examcode') {
- $desc = $value;
- } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
- foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
- next unless (ref($possibilities) eq 'ARRAY');
- my ($parmval, $description) = @{ $possibilities };
- if ($parmval eq $value) {
- $desc = $description;
- last;
- }
- }
- }
- } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
- my $now = time;
- if ($value =~ /^\d+$/) {
- if ($name eq 'printstartdate') {
- if ($value > $now) {
- $desc = &Apache::lonlocal::locallocaltime($value);
- }
- } elsif ($name eq 'printenddate') {
- if ($value < $now) {
- $desc = &Apache::lonlocal::locallocaltime($value);
- }
- }
- }
- }
- my $standard_name = &standard_parameter_names($name);
- return ''.
- &mt('[_1] was [_2]not[_3] set to [_4].',
- $standard_name,'',' ','"'.$desc.'"').' '.
- &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
- $cmajor.'.'.$cminor,$chostname,
- $needsrelease).
- '
';
-}
-
-}
-
#
# Shift all start and end dates by $shift
#
@@ -4416,8 +3668,6 @@ sub newoverview {
'.
&Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
&showhide_js()."\n".
- &done_proctor_js()."\n".
- &deeplink_js()."\n".
'// ]]>
';
@@ -4492,10 +3742,8 @@ ENDOVER
$r->print('');
$r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
&levelmenu($r,\%alllevs,$parmlev);
- if ($parmlev ne 'general') {
- $r->print(&Apache::lonhtmlcommon::row_closure());
- &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp);
- }
+ $r->print(&Apache::lonhtmlcommon::row_closure());
+ &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev);
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print('
');
@@ -4607,20 +3855,13 @@ sub overview {
my ($r,$parm_permission) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
- my $js = ''."\n";
my $readonly = 1;
if ($parm_permission->{'edit'}) {
undef($readonly);
}
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
- my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js);
+ my $start_page=&Apache::loncommon::start_page('Modify Parameters');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print($start_page.$breadcrumbs);
$r->print('