--- loncom/interface/lonparmset.pm 2016/10/27 23:17:42 1.522.2.21 +++ loncom/interface/lonparmset.pm 2022/05/31 14:31:45 1.522.2.28.4.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.21 2016/10/27 23:17:42 raeburn Exp $ +# $Id: lonparmset.pm,v 1.522.2.28.4.6 2022/05/31 14:31:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,7 +36,8 @@ lonparmset - Handler to set parameters f =head1 SYNOPSIS -lonparmset provides an interface to setting course parameters. +lonparmset provides an interface to setting content parameters in a +course. =head1 DESCRIPTION @@ -129,7 +130,7 @@ javascript function 'pjump'. =item print_td() -=item print_usergroups() +=item check_other_groups() =item parm_control_group() @@ -766,7 +767,17 @@ sub valout { } } else { if ($type eq 'date_interval') { - my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); + 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 @timer; $year=$year-70; $mday--; @@ -799,6 +810,13 @@ 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); @@ -813,11 +831,15 @@ sub valout { sub plink { - my ($type,$dis,$value,$marker,$return,$call)=@_; + my ($type,$dis,$value,$marker,$return,$call,$extra)=@_; my $winvalue=$value; unless ($winvalue) { - if (&isdateparm($type)) { + if ((&isdateparm($type)) || (&is_specialstring($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]}; } @@ -828,13 +850,13 @@ sub plink { my $valout = &valout($value,$type,1); my $unencmarker = $marker; foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, - \$hour, \$min, \$sec) { + \$hour, \$min, \$sec, \$extra) { $$item = &HTML::Entities::encode($$item,'"<>&'); $$item =~ s/\'/\\\'/g; } return '
'. ''. + .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."','".$extra."'".');">'. $valout.'
'; } @@ -850,20 +872,22 @@ 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') { - 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') || + (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;'); + } } - } document.parmform.submit(); } else { document.parmform.pres_value.value=''; @@ -905,6 +929,306 @@ 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 dlTargetRegExp = /^deeplink_target_/; + 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; + } + } else if (dlTargetRegExp.test(name)) { + var identifier = name.replace(dlTargetRegExp,''); + var idx = document.parmform.elements[i].selectedIndex; + if (idx > 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; + } + } + } + } + } + } + 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); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } elsif ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra); } elsif ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } else { - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } } elsif ($parmlev eq 'map') { if ($uname) { - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } elsif ($cgroup) { - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra); } elsif ($csec) { - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } else { - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra); } } else { if ($uname) { if (@{$usersgroups} > 1) { my ($coursereply,$grp_parm,$controlgrp); ($coursereply,$othergrp,$grp_parm,$controlgrp) = - &print_usergroups($r,$$part{$which}.'.'.$$name{$which}, + &check_other_groups($$part{$which}.'.'.$$name{$which}, $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); if ($coursereply && $result > 3) { if (defined($controlgrp)) { @@ -1037,32 +1409,32 @@ sub print_row { } } - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,14,$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); + &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); if ($csec) { - &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); + &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); } if ($cgroup) { - &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); + &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); } if ($uname) { if ($othergrp) { $r->print($othergrp); } - &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); + &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); } } # end of $parmlev if/else @@ -1082,7 +1454,7 @@ sub print_row { } sub print_td { - my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_; + my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly,$extra)=@_; $r->print(''); my $nolink = 0; @@ -1091,10 +1463,14 @@ sub print_td { } else { if ($which == 11 || $which == 12) { $nolink = 1; - } elsif ($mprefix =~ /availablestudent\&$/) { - if ($which > 3) { + } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) { + $nolink = 1; + } elsif ($which == 4 || $which == 5 || $which == 6) { + if ($noeditgrp) { $nolink = 1; } + } elsif ($mprefix =~ /availablestudent\&$/) { + $nolink = 1; } elsif ($mprefix =~ /examcode\&$/) { unless ($which == 2) { $nolink = 1; @@ -1106,13 +1482,13 @@ sub print_td { } else { $r->print(&plink($$typeoutpar[$which], $$display{$value},$$outpar[$which], - $mprefix."$which",'parmform.pres','psub')); + $mprefix."$which",'parmform.pres','psub',$extra)); } $r->print(''."\n"); } -sub print_usergroups { - my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; +sub check_other_groups { + my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; my $courseid = $env{'request.course.id'}; my $output; my $symb = &symbcache($rid); @@ -1127,7 +1503,6 @@ sub print_usergroups { if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { $bgcolor = '#AAFFAA'; - $grp_parm = &valout($coursereply,$resulttype); } $grp_parm = &valout($coursereply,$resulttype); $output = ''; @@ -1273,14 +1648,21 @@ 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 # from which you can select all desired parameters. # sub parmmenu { - my ($r,$allparms,$pscat,$keyorder)=@_; - my $tempkey; + my ($r)=@_; $r->print(< // print('
'); - &shortCuts($r,$allparms,$pscat,$keyorder); + &shortCuts($r); $r->print('
'); } # return a hash @@ -1408,6 +1790,7 @@ sub lookUpTableParameter { 'buttonshide' => 'hiding', 'turnoffeditor' => 'hiding', 'encrypturl' => 'hiding', + 'deeplink' => 'hiding', 'randomorder' => 'high_level_randomization', 'randompick' => 'high_level_randomization', 'available' => 'slots', @@ -1424,7 +1807,7 @@ sub lookUpTableParameter { 'retrypartial' => 'tries', 'discussvote' => 'misc', 'examcode' => 'high_level_randomization', - ); + ); } sub whatIsMyCategory { @@ -1506,6 +1889,7 @@ sub parmboxes { .&mt($categories{$key}) .''."\n"); foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { + next if ($tempkey eq ''); $r->print('' .'  '. + ''; my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); my $groups; - my %grouphash = &Apache::longroup::coursegroups(); + my %grouphash; + if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { + %grouphash = &Apache::longroup::coursegroups(); + } elsif ($env{'request.course.groups'} ne '') { + map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); + } my $g_s_header=''; my $g_s_footer=''; - if (%sectionhash) { + my $currsec = $env{'request.course.sec'}; + if ($currsec) { + $sections=&mt('Section:').' '.$currsec; + if (%grouphash) { + $sections .= ';'.(' ' x2); + } + } elsif (%sectionhash && $currsec eq '') { $sections=&mt('Section:').' '); + $thiskey.'"'.$disabled.' />'); } $r->print(''); $foundkeys++; @@ -3159,9 +3795,12 @@ sub listdata { ); } } elsif ($thistype eq 'date_interval') { - $r->print(&date_interval_selector($thiskey, + $r->print(&date_interval_selector($thiskey,$name, $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { + if ($name eq 'availablestudent') { + $readonly = 1; + } $r->print(&string_selector($thistype,$thiskey, $$resourcedata{$thiskey},$name,$readonly)); } else { @@ -3179,8 +3818,9 @@ sub listdata { sub date_interval_selector { - my ($thiskey, $showval, $readonly) = @_; - my $result; + my ($thiskey, $pname, $showval, $readonly) = @_; + my ($result,%skipval); + my $currval = $showval; foreach my $which (['days', 86400, 31], ['hours', 3600, 23], ['minutes', 60, 59], @@ -3194,6 +3834,51 @@ sub date_interval_selector { \%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'). + ''.(' 'x2). + ''.(' 'x2). + ''. + '&').'"'.$disabled.' />
'. + ''.&mt('Button text').': '. + '&').'"'.$disabled.' />'; + } + } unless ($readonly) { $result .= ''; } @@ -3226,6 +3911,283 @@ 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".''; + } + my $output = ' +'; + foreach my $acctype ('allow','deny') { + $output .= ' +'; + } + $output .= ' + +
'.&mt('Allow from').''.&mt('Deny from').'
+
+
'."\n"; + my $num = 0; + foreach my $curr (@{$access{$acctype}}) { + $output .= '
'; + if ($num > 0) { + $output .= ''.&mt('Remove').''; + } + $output .= '
'."\n"; + $num ++; + } + $output .= ' +
'.$addmore.' +
+
'."\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','target'); + %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', + target => 'Embedded?', + ); + %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'], + target => ['_self','_top'], + ); + %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', + _self => 'Embedded', + _top => 'Not embedded', + ); + %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+)$/); + ($values{'target'}) = ($current[6] =~ /^(_self|_top)$/); + } else { + $defaults{'state'} = 'off', + $defaults{'others'} = 'unhide', + $defaults{'listing'} = 'full'; + $defaults{'scope'} = 'res'; + $defaults{'protect'} = 'none'; + $defaults{'menus'} = '0'; + $defaults{'target'} = '_top'; + } + 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 = ''; + foreach my $item (@components) { + $output .= ''; + } + $output .= ''; + foreach my $item (@components) { + $output .= ''; + } + $output .= '
'.$titles{$item}.'
'; + if (($item eq 'protect') || ($item eq 'menus')) { + my $selected = $values{$item}; + foreach my $option (@{$options{$item}}) { + if ($item eq 'protect') { + if ($option eq 'ltid') { + next unless (keys(%domlti)); + } elsif ($option eq 'ltic') { + next unless (keys(%crslti)); + } + } elsif (($item eq 'menus') && ($option eq 'colls')) { + next unless (@possmenus); + } + my $checked; + if ($item eq 'menus') { + if (($selected =~ /^\d+$/) && (@possmenus) && + (grep(/^\Q$selected\E$/,@possmenus))) { + if ($option eq 'colls') { + $checked = ' checked="checked"'; + } + } elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) { + $checked = ' checked="checked"'; + } + } elsif ($selected =~ /^\Q$option\E/) { + $checked = ' checked="checked"'; + } + my $onclick; + unless ($readonly) { + my $esc_key = &js_escape($thiskey); + $onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"'; + } + $output .= ''; + if (($item eq 'protect') && ($option eq 'key')) { + my $visibility="hidden"; + my $currkey; + if ($checked) { + $visibility = "text"; + $currkey = (split(/\:/,$values{$item}))[1]; + } + $output .= ' '. + ''; + } elsif (($option eq 'ltic') || ($option eq 'ltid') || ($option eq 'colls')) { + my $display="none"; + my ($current,$blankcheck,@possibles); + if ($checked) { + $display = 'inline-block'; + if (($option eq 'ltic') || ($option eq 'ltid')) { + $current = (split(/\:/,$selected))[1]; + } else { + $current = $selected; + } + } else { + $blankcheck = ' selected="selected"'; + } + if ($option eq 'ltid') { + @possibles = keys(%domlti); + } elsif ($option eq 'ltic') { + @possibles = keys(%crslti); + } else { + @possibles = @possmenus; + } + $output .= '
 
'; + } + $output .= '
'; + } + } else { + my $selected = $values{$item}; + my $defsel; + if ($selected eq '') { + $defsel = ' selected="selected"'; + } + $output .= ''; + } + $output .= '
'."\n"; + return $output; +} + +{ + my %strings = ( 'string_yesno' @@ -3253,8 +4215,31 @@ 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, shown menu items, and embedding']], ); +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+|)\,_(self|top)$']], + ); + +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') { @@ -3263,6 +4248,14 @@ 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) = @_; @@ -3293,6 +4286,12 @@ 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); @@ -3347,14 +4346,76 @@ 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 # sub dateshift { - my ($shift)=@_; + my ($shift,$numchanges)=@_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $sec = $env{'request.course.sec'}; + my $secgrpregex; + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $secgrpregex = '(?:'.join('|',($sec,@groups)).')'; + } else { + $secgrpregex = $sec; + } + } my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs); # ugly retro fix for broken version of types foreach my $key (keys %data) { @@ -3369,7 +4430,11 @@ sub dateshift { # go through all parameters and look for dates foreach my $key (keys %data) { if ($data{$key.'.type'}=~/^date_(start|end)$/) { + if ($sec ne '') { + next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./); + } my $newdate=$data{$key}+$shift; + $$numchanges ++; $storecontent{$key}=$newdate; } } @@ -3403,6 +4468,10 @@ sub newoverview { '. &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n". &showhide_js()."\n". + &validateparms_js()."\n". + &ipacc_boxes_js()."\n". + &done_proctor_js()."\n". + &deeplink_js()."\n". '// ]]> '; @@ -3411,7 +4480,7 @@ sub newoverview { my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); $r->print(< +
ENDOVER my @ids=(); my %typep=(); @@ -3448,6 +4517,9 @@ ENDOVER @selected_sections = ('all'); } } + if ($env{'request.course.sec'} ne '') { + @selected_sections = ($env{'request.course.sec'}); + } my @selected_groups = &Apache::loncommon::get_env_multiple('form.Group'); @@ -3487,16 +4559,26 @@ ENDOVER &displaymenu($r,\%allparms,\@pscat,\%keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); + my $sectionselector = §ionmenu(\@selected_sections); + my $groupselector = &groupmenu(\@selected_groups); $r->print(''. - ''); + if ($sectionselector) { + $r->print(''); + } + if ($groupselector) { + $r->print(''); + } + $r->print('
'.&mt('Parts').''.&mt('Section(s)'). - ''.&mt('Group(s)').'
'); + '
'.&mt('Parts').''.&mt('Section(s)').''.&mt('Group(s)').'
'); &partmenu($r,\%allparts,\@psprt); - $r->print(''); - §ionmenu($r,\@selected_sections); - $r->print(''); - &groupmenu($r,\@selected_groups); - $r->print('
'); - #$r->print(''); + $r->print(''); + if ($sectionselector) { + $r->print(''.$sectionselector.''); + } + if ($groupselector) { + $r->print(''.$groupselector.''); + } + $r->print(''); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print(''); @@ -3579,16 +4661,25 @@ 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'); + my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); - $r->print(''); + $r->print(''); # Store modified unless ($readonly) { @@ -3685,10 +4776,8 @@ ENDOVER $r->print(&mt('All users')); } elsif ($data{'scope_type'} eq 'user') { $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); - } elsif ($data{'scope_type'} eq 'section') { - $r->print(&mt('Section: [_1]',$data{'scope'})); - } elsif ($data{'scope_type'} eq 'group') { - $r->print(&mt('Group: [_1]',$data{'scope'})); + } elsif ($data{'scope_type'} eq 'secgroup') { + $r->print(&mt('Group/Section: [_1]',$data{'scope'})); } $r->print('
'); if ($data{'realm_type'} eq 'all') { @@ -3717,9 +4806,21 @@ sub date_shift_one { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - + my $sec = $env{'request.course.sec'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); + my $submit_text = &mt('Shift all dates accordingly'); + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $submit_text = &mt("Shift dates set just for your section/group(s), accordingly"); + } else { + $submit_text = &mt("Shift dates set just for your section, accordingly"); + } + } my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); @@ -3734,7 +4835,7 @@ sub date_shift_one { ''. ''. ''. - '
'); + ''); $r->print(&Apache::loncommon::end_page()); } @@ -3742,20 +4843,54 @@ sub date_shift_two { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $sec = $env{'request.course.sec'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); - $r->print('

'.&mt('Shift Dates').'

'. - '

'.&mt('Shifting all dates such that [_1] becomes [_2]', - &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted)).'

'); + $r->print('

'.&mt('Shift Dates').'

'); + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $r->print('

'. + &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]", + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } else { + $r->print('

'. + &mt("Shift dates set just for your section, such that [_1] becomes [_2]", + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } + } else { + $r->print('

'.&mt('Shifting all dates such that [_1] becomes [_2]', + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } my $delta=$timeshifted-$env{'form.timebase'}; - &dateshift($delta); + my $numchanges = 0; + my $result = &dateshift($delta,\$numchanges); + if ($result eq 'ok') { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]', + $numchanges))); + } elsif ($result eq 'con_delayed') { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]', + $numchanges))); + } else { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1)); + } $r->print( - &Apache::lonhtmlcommon::confirm_success(&mt('Done')). '

'. &Apache::lonhtmlcommon::actionbox( [''.&mt('Content and Problem Settings').''])); @@ -3774,8 +4909,7 @@ sub parse_key { $data{'scope_type'} = 'user'; $data{'scope'} = [$1,$2]; } else { - #FIXME check for group scope - $data{'scope_type'} = 'section'; + $data{'scope_type'} = 'secgroup'; } $middle=~s/^\[(.*)\]//; } @@ -4089,7 +5223,7 @@ sub continue { my $output; $output .= '
'; $output .= ''; - $output .= ''; + $output .= ''; return ($output); } @@ -4111,7 +5245,10 @@ sub addmetafield { my $put_result = &Apache::lonnet::put('environment', {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); - $r->print('Undeleted Metadata Field '.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}." with result ".$put_result.'
'); + $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]', + ''.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}. + '',$put_result). + '
'); } $r->print(&continue()); } elsif (exists($env{'form.fieldname'})) { @@ -4123,12 +5260,17 @@ sub addmetafield { {'metadata.'.$meta_field.'.values'=>"", 'metadata.'.$meta_field.'.added'=>"$display_field", 'metadata.'.$meta_field.'.options'=>""},$dom,$crs); - $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result.'
'); + $r->print(&mt('Added new Metadata Field [_1] with result [_2]', + ''.$env{'form.fieldname'}.'',$put_result). + '
'); $r->print(&continue()); } else { my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); if ($fields) { - $r->print('You may undelete previously deleted fields.
Check those you wish to undelete and click Undelete.
'); + $r->print(&mt('You may undelete previously deleted fields.'). + '
'. + &mt('Check those you wish to undelete and click Undelete.'). + '
'); $r->print(''); foreach my $key(keys(%$fields)) { $r->print(''.$$fields{$key}.'
print(''); $r->print('
'); } - $r->print('
Or you may enter a new metadata field name.
print('
'. + &mt('[_1]Or[_2] you may enter a new metadata field name.', + '',''). + ''); $r->print('
'); - $r->print(''); + $r->print(''); } $r->print('
'); } @@ -4159,6 +5304,11 @@ sub setrestrictmeta { my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; my $save_field = ''; + my %lt = &Apache::lonlocal::texthash( + addm => 'Add Metadata Field', + ordm => 'Order Metadata Fields', + save => 'Save', + ); if ($env{'form.restrictmeta'}) { foreach my $field (sort(keys(%env))) { if ($field=~m/^form.(.+)_(.+)$/) { @@ -4197,28 +5347,25 @@ sub setrestrictmeta { my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); # Now get possible added metadata fields my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); - my $row_alt = 1; $output .= &Apache::loncommon::start_data_table(); foreach my $field (sort(keys(%metadata_fields))) { if ($field ne 'courserestricted') { - $row_alt = $row_alt ? 0 : 1; $output.= &output_row($r, $field, $metadata_fields{$field}); } } my $buttons = (< +
- +

- + ENDButtons my $added_flag = 1; foreach my $field (sort(keys(%$added_metadata_fields))) { - $row_alt = $row_alt ? 0 : 1; - $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt); + $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag); } $output .= &Apache::loncommon::end_data_table(); $r->print(<) { if ($configline !~ /\S/ || $configline=~/^\#/) { next; } chomp($configline); @@ -4478,6 +5625,7 @@ sub load_parameter_names { close($config); $standard_parms{'int_pos'} = 'Positive Integer'; $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; + $standard_parms{'scoreformat'} = 'Format for display of score'; } sub standard_parameter_names { @@ -4557,6 +5705,12 @@ sub parm_change_log { } if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } } + my $numgroups = 0; + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + $numgroups = scalar(@groups); + } foreach my $id (sort { if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { @@ -4596,6 +5750,14 @@ sub parm_change_log { !exists($parmlog{$id}{'logentry'}{$changed.'.type'})); my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); + if ($env{'request.course.sec'} ne '') { + next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) || + ($numgroups && (grep(/^\Q$issection\E$/,@groups)))))); + if ($uname ne '') { + my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'}); + next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); + } + } if ($env{'form.displayfilter'} eq 'currentfolder') { if ($folder) { if ($middle!~/^\Q$folder\E/) { next; } @@ -4812,53 +5974,6 @@ sub parameter_releasecheck { return $needsnewer; } -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). - '

'; -} - sub get_permission { my %permission; my $allowed = 0;