--- loncom/interface/lonparmset.pm 2017/02/16 18:17:49 1.572
+++ loncom/interface/lonparmset.pm 2017/07/15 04:58:17 1.581
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.572 2017/02/16 18:17:49 damieng Exp $
+# $Id: lonparmset.pm,v 1.581 2017/07/15 04:58:17 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.
It contains all the code for the "Content and Problem Settings" UI, except
for the helpers parameter.helper and resettimes.helper, and lonhelper.pm,
@@ -137,7 +138,7 @@ javascript function 'pjump'.
=item print_td()
-=item print_usergroups()
+=item check_other_groups()
=item parm_control_group()
@@ -846,17 +847,36 @@ sub storeparm_by_symb_inner {
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
my $storeunder='';
+ my $possreplace='';
if (($snum==18) || ($snum==4)) { $storeunder=$courselevel; }
- if (($snum==17) || ($snum==3)) { $storeunder=$courseleveli; }
- if (($snum==16) || ($snum==2)) { $storeunder=$courselevelm; }
+ if (($snum==17) || ($snum==3)) {
+ $storeunder=$courseleveli;
+ $possreplace=$courselevelm;
+ }
+ if (($snum==16) || ($snum==2)) {
+ $storeunder=$courselevelm;
+ $possreplace=$courseleveli;
+ }
if (($snum==13) || ($snum==1)) { $storeunder=$courselevelr; }
if ($snum==12) { $storeunder=$seclevel; }
- if ($snum==11) { $storeunder=$secleveli; }
- if ($snum==10) { $storeunder=$seclevelm; }
+ if ($snum==11) {
+ $storeunder=$secleveli;
+ $possreplace=$seclevelm;
+ }
+ if ($snum==10) {
+ $storeunder=$seclevelm;
+ $possreplace=$secleveli;
+ }
if ($snum==9) { $storeunder=$seclevelr; }
if ($snum==8) { $storeunder=$grplevel; }
- if ($snum==7) { $storeunder=$grpleveli; }
- if ($snum==6) { $storeunder=$grplevelm; }
+ if ($snum==7) {
+ $storeunder=$grpleveli;
+ $possreplace=$grplevelm;
+ }
+ if ($snum==6) {
+ $storeunder=$grplevelm;
+ $possreplace=$grpleveli;
+ }
if ($snum==5) { $storeunder=$grplevelr; }
@@ -875,7 +895,7 @@ sub storeparm_by_symb_inner {
&Apache::lonnet::expirespread('','','studentcalc');
if (($snum==13) || ($snum==9) || ($snum==5)) {
&Apache::lonnet::expirespread('','','assesscalc',$symb);
- } elsif (($snum==14) || ($snum==10) || ($snum==6)) {
+ } elsif (($snum==17) || ($snum==16) || ($snum==11) || ($snum==10) || ($snum==7) || ($snum==6)) {
&Apache::lonnet::expirespread('','','assesscalc',$map);
} else {
&Apache::lonnet::expirespread('','','assesscalc');
@@ -889,6 +909,17 @@ sub storeparm_by_symb_inner {
$reply=&Apache::lonnet::cput
('resourcedata',\%storecontent,$cdom,$cnum);
&log_parmset(\%storecontent);
+ if ($possreplace) {
+ my $resdata = &Apache::lonnet::get_courseresdata($cnum,$cdom);
+ if (ref($resdata) eq 'HASH') {
+ if (exists($resdata->{$possreplace})) {
+ if (&Apache::lonnet::del
+ ('resourcedata',[$possreplace,$possreplace.'.type'],$cdom,$cnum) eq 'ok') {
+ &log_parmset({$possreplace => '', $possreplace.'.type' => $ntype},1);
+ }
+ }
+ }
+ }
}
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
} else {
@@ -899,7 +930,7 @@ sub storeparm_by_symb_inner {
if ($snum==1) {
&Apache::lonnet::expirespread
($uname,$udom,'assesscalc',$symb);
- } elsif ($snum==2) {
+ } elsif (($snum==2) || ($snum==3)) {
&Apache::lonnet::expirespread
($uname,$udom,'assesscalc',$map);
} else {
@@ -914,6 +945,18 @@ sub storeparm_by_symb_inner {
$reply=&Apache::lonnet::cput
('resourcedata',\%storecontent,$udom,$uname);
&log_parmset(\%storecontent,0,$uname,$udom);
+ if ($possreplace) {
+ my $resdata = &Apache::lonnet::get_userresdata($uname,$udom);
+ if (ref($resdata) eq 'HASH') {
+ if (exists($resdata->{$possreplace})) {
+ if (&Apache::lonnet::del
+ ('resourcedata',[$possreplace,$possreplace.'.type'],$udom,$uname) eq 'ok') {
+ &log_parmset({$possreplace => '',$possreplace.'.type' => $ntype},1,
+ $uname,$udom);
+ }
+ }
+ }
+ }
}
&Apache::lonnet::devalidateuserresdata($uname,$udom);
}
@@ -1022,8 +1065,9 @@ sub valout {
# @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change.
# @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres')
# @param {string} $call - javascript function to call to submit the form ('psub')
+# @param {boolean} $recursive - true if link is for a map/folder where parameter is currently set to be recursive.
sub plink {
- my ($type,$dis,$value,$marker,$return,$call)=@_;
+ my ($type,$dis,$value,$marker,$return,$call,$recursive)=@_;
my $winvalue=$value;
unless ($winvalue) {
if (&isdateparm($type)) {
@@ -1045,7 +1089,9 @@ sub plink {
return '
';
+ $valout.''.($recursive?''.
+ &mt('recursive').' ' : '').'';
+
}
# Javascript for table mode.
@@ -1425,8 +1471,10 @@ sub print_row {
$thismarker=~s/^parameter\_//;
my $mprefix=$rid.'&'.$thismarker.'&';
my $effective_parm = &valout($outpar[$result],$typeoutpar[$result],$thismarker);
- my ($othergrp,$grp_parm,$controlgrp);
-
+ my ($othergrp,$grp_parm,$controlgrp,$effparm_rec);
+ if ($result == 17 || $result == 11 || $result == 7 || $result == 3) {
+ $effparm_rec = 1;
+ }
if ($parmlev eq 'general') {
if ($uname) {
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
@@ -1439,24 +1487,20 @@ sub print_row {
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
} elsif ($cgroup) {
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1);
} elsif ($csec) {
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
} else {
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
}
} 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 > 4) {
if (defined($controlgrp)) {
@@ -1470,23 +1514,20 @@ sub print_row {
}
&print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
&print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
&print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
&print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
if ($csec) {
&print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
&print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
if ($cgroup) {
&print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1);
&print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly);
}
@@ -1495,13 +1536,14 @@ sub print_row {
$r->print($othergrp);
}
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} # end of $parmlev if/else
- $r->print(''.$effective_parm.' ');
+ $r->print(''.$effective_parm.
+ ($effparm_rec?''.&mt('recursive').
+ ' ':'').' ');
if ($parmlev eq 'full') {
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
@@ -1535,15 +1577,40 @@ sub print_row {
# @param {hash reference} $display - parameter key -> full title for the parameter
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
# @param {boolean} $readonly -true if editing not allowed.
+# @param {boolean} $ismaplevel - true if level is for a map.
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_;
- $r->print('');
my $nolink = 0;
if ($readonly) {
$nolink = 1;
} else {
- if ($which == 14 || $which == 15) {
+ if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&$/) {
$nolink = 1;
} elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
$nolink = 1;
@@ -1562,21 +1629,19 @@ sub print_td {
}
}
if ($nolink) {
- $r->print(&valout($$outpar[$which],$$typeoutpar[$which],$mprefix));
-# FIXME: probably a good thing that mprefix is not used in valout, because it does not look like a parameter name !
+ my ($parmname)=((split(/\&/,$mprefix))[1]=~/\_([^\_]+)$/);
+ $r->print(&valout($currval,$currtype,$parmname));
} else {
- $r->print(&plink($$typeoutpar[$which],
- $$display{$value},$$outpar[$which],
- $mprefix."$which",'parmform.pres','psub'));
+ $r->print(&plink($currtype,
+ $$display{$value},$currval,
+ $mprefix.$currlevel,'parmform.pres','psub',$recursive));
}
$r->print(' '."\n");
}
-# FIXME: Despite the name, this does not print anything, the $r parameter is unused.
# Returns HTML and other info for the cell added when a user is selected
# and that user is in several groups. This is the cell with the title "Control by other group".
#
-# @param {Apache2::RequestRec} $r - the Apache request (unused)
# @param {string} $what - parameter part.'.'.parameter name
# @param {string} $rid - resource id
# @param {string} $cgroup - group name
@@ -1585,8 +1650,8 @@ sub print_td {
# @param {integer} $result - level
# @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db)
# @returns {Array} - array (parameter value for the other group, HTML for the cell, HTML with the value, name of the other group)
-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);
@@ -1602,7 +1667,6 @@ sub print_usergroups {
if (($coursereply) && ($cgroup ne $resultgroup)) {
if ($result > 3) {
$bgcolor = '#AAFFAA';
- $grp_parm = &valout($coursereply,$resulttype,$what);
}
$grp_parm = &valout($coursereply,$resulttype,$what);
$output = '';
@@ -1619,7 +1683,7 @@ sub print_usergroups {
}
# Looks for a group with a defined parameter for given user and parameter.
-# Used by print_usergroups.
+# Used by check_other_groups.
#
# @param {string} $courseid - the course id
# @param {array reference} $usersgroups - list of groups the user belongs to, if any
@@ -1780,15 +1844,10 @@ sub isdateparm {
}
# Prints the HTML and Javascript to select parameters, with various shortcuts.
-# FIXME: remove unused parameters
#
-# @param {Apache2::RequestRec} $r - the Apache request (unused)
-# @param {hash reference} $allparms - hash parameter name -> parameter title
-# @param {array reference} $pscat - list of selected parameter names (unused)
-# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused)
+# @param {Apache2::RequestRec} $r - the Apache request
sub parmmenu {
- my ($r,$allparms,$pscat,$keyorder)=@_;
- my $tempkey;
+ my ($r)=@_;
$r->print(<
// print(' ');
- &shortCuts($r,$allparms,$pscat,$keyorder);
+ &shortCuts($r);
$r->print(' ');
}
@@ -1935,7 +1994,7 @@ sub lookUpTableParameter {
'retrypartial' => 'tries',
'discussvote' => 'misc',
'examcode' => 'high_level_randomization',
- );
+ );
}
# Adds the given parameter name to an array of arrays listing all parameters for each category.
@@ -2029,6 +2088,7 @@ sub parmboxes {
$r->print(''
.'
'.&mt($categories{$key}).' '."\n");
foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
+ next if ($tempkey eq '');
$r->print('
'
.' parameter title (unused)
-# @param {array reference} $pscat - list of selected parameter names (unused)
-# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused)
sub shortCuts {
- my ($r,$allparms,$pscat,$keyorder)=@_;
+ my ($r)=@_;
# Parameter Selection
$r->print(
@@ -2245,16 +2301,15 @@ function group_or_section(caller) {
# @param {Apache2::RequestRec} $r - the Apache request
# @param {hash reference} $allparms - hash parameter name -> parameter title
# @param {array reference} $pscat - list of selected parameter names
-# @param {array reference} $psprt - list of selected parameter parts (unused)
# @param {hash reference} $keyorder - hash parameter key -> appearance rank
# @param {string} [$divid] - name used to give an id to the HTML element for the scroll box
sub displaymenu {
- my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_;
+ my ($r,$allparms,$pscat,$keyorder,$divid)=@_;
$r->print(&Apache::lonhtmlcommon::start_pick_box());
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
- &parmmenu($r,$allparms,$pscat,$keyorder); # only $allparms is used by parmmenu
+ &parmmenu($r);
$r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));
&parmboxes($r,$allparms,$pscat,$keyorder);
$r->print(&Apache::loncommon::end_scrollbox());
@@ -3038,7 +3093,7 @@ ENDPARMSELSCRIPT
# Step 2
$r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
- &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll');
+ &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
# Step 3
$r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
@@ -3114,10 +3169,10 @@ ENDPARMSELSCRIPT
#
# This produces the cascading table output of parameters
#
- my $coursespan=$csec?10:6;
- my $userspan=4;
+ my $coursespan=$csec?8:5;
+ my $userspan=3;
if ($cgroup ne '') {
- $coursespan += 4;
+ $coursespan += 3;
}
$r->print(&Apache::loncommon::start_data_table());
@@ -3147,44 +3202,43 @@ ENDPARMSELSCRIPT
'femof' => 'from Enclosing Map or Folder',
'gen' => 'general',
'foremf' => 'for Enclosing Map or Folder',
- 'formfr' => 'for Map or Folder (recursive)',
'fr' => 'for Resource'
);
$r->print(<$lt{'pie'}
$lt{'csv'} ($csuname:$csudom)
-$lt{'ic'} $lt{'rl'}
+$lt{'ic'} $lt{'rl'}
$lt{'ic'}
ENDTABLETWO
if ($csec) {
- $r->print(''.
+ $r->print(' '.
&mt("in Section")." $csec ");
}
if ($cgroup) {
- $r->print(''.
+ $r->print(' '.
&mt("in Group")." $cgroup ");
}
$r->print(<$lt{'aut'} $lt{'type'}
$lt{'emof'} $lt{'part'} $lt{'pn'}
-$lt{'gen'} $lt{'formfr'} $lt{'foremf'}
+$lt{'gen'} $lt{'foremf'}
$lt{'def'} $lt{'femof'} $lt{'fr'}
ENDTABLEHEADFOUR
if ($csec) {
- $r->print(''.$lt{'gen'}.' '.$lt{'formfr'}.' '.$lt{'foremf'}.' '.$lt{'fr'}.' ');
+ $r->print(''.$lt{'gen'}.' '.$lt{'foremf'}.' '.$lt{'fr'}.' ');
}
if ($cgroup) {
- $r->print(''.$lt{'gen'}.' '.$lt{'formfr'}.' '.&mt('foremf').' '.$lt{'fr'}.' ');
+ $r->print(''.$lt{'gen'}.' '.$lt{'foremf'}.' '.$lt{'fr'}.' ');
}
if ($uname) {
if (@usersgroups > 1) {
$r->print(''.&mt('Control by other group?').' ');
}
- $r->print(''.$lt{'gen'}.' '.$lt{'formfr'}.' '.$lt{'foremf'}.' '.$lt{'fr'}.' ');
+ $r->print(''.$lt{'gen'}.' '.$lt{'foremf'}.' '.$lt{'fr'}.' ');
}
$r->print(' ');
@@ -3405,8 +3459,7 @@ ENDTABLEHEADFOUR
$r->print(''.&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
.'
'.&mt('Parameter Name').' '
- .''.&mt('Recursive Value').' '
- .''.&mt('Non-Recursive Value').' '
+ .''.&mt('Value').' '
.''.&mt('Parameter in Effect').' '
.&Apache::loncommon::end_data_table_header_row()
);
@@ -3532,7 +3585,7 @@ my $tableopen; # boolean, true if HTML t
# @param {boolean} $readonly - true if values cannot be edited (otherwise more columns are added)
# @returns {string}
sub tablestart {
- my ($readonly) = @_;
+ my ($readonly,$is_map) = @_;
if ($tableopen) {
return '';
} else {
@@ -3541,7 +3594,11 @@ sub tablestart {
if ($readonly) {
$output .= ''.&mt('Current value').' ';
} else {
- $output .= ''.&mt('Delete').' '.&mt('Set to ...').' ';
+ $output .= ''.&mt('Delete').' '.
+ ''.&mt('Set to ...').' ';
+ if ($is_map) {
+ $output .= ''.&mt('Recursive?').' ';
+ }
}
$output .= ' ';
return $output;
@@ -3620,6 +3677,8 @@ sub storedata {
my %newdata=();
undef %newdata;
my @deldata=();
+ my @delrec=();
+ my @delnonrec=();
undef @deldata;
my ($got_chostname,$chostname,$cmajor,$cminor);
my $now = time;
@@ -3627,11 +3686,27 @@ sub storedata {
if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
my $cmd=$1;
my $thiskey=$2;
- next if ($cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny');
+ my ($altkey,$recursive,$tkey,$tkeyrec,$tkeynonrec);
+ next if ($cmd eq 'rec' || $cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny');
+ if ((($cmd eq 'set') || ($cmd eq 'datepointer') || ($cmd eq 'dateinterval') || ($cmd eq 'del')) &&
+ ($thiskey =~ /(?:sequence|page)\Q___(all)\E/)) {
+ unless ($thiskey =~ /(encrypturl|hiddenresource)$/) {
+ $altkey = $thiskey;
+ $altkey =~ s/\Q___(all)\E/___(rec)/;
+ if ($env{'form.rec_'.$thiskey}) {
+ $recursive = 1;
+ }
+ }
+ }
my ($tuname,$tudom)=&extractuser($thiskey);
- my $tkey=$thiskey;
if ($tuname) {
+ $tkey=$thiskey;
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
+ if ($altkey) {
+ $tkeynonrec = $tkey;
+ $tkeyrec = $altkey;
+ $tkeyrec=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
+ }
}
if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch);
@@ -3715,7 +3790,7 @@ sub storedata {
$typeof=$env{'form.typeof_'.$thiskey};
$text = &mt('Saved modified date for');
}
- if ($thiskey =~ m{\.(?:sequence|page)___\(rec\)}) {
+ if ($recursive) {
$namematch = 'maplevelrecurse';
}
if (($name ne '') || ($namematch ne '')) {
@@ -3762,54 +3837,195 @@ sub storedata {
next;
}
}
- if (defined($data) and $$olddata{$thiskey} ne $data) {
- if ($tuname) {
- if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
- $tkey.'.type' => $typeof},
- $tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
- $r->print(' '.$text.' '.
- &Apache::loncommon::plainname($tuname,$tudom));
+ my ($reconlychg,$haschange,$storekey);
+ if ($tuname) {
+ my $ustorekey;
+ if ($altkey) {
+ if ($recursive) {
+ if (exists($$olddata{$thiskey})) {
+ if ($$olddata{$thiskey} eq $data) {
+ $reconlychg = 1;
+ }
+ &Apache::lonnet::del('resourcedata',[$tkeynonrec,$tkeynonrec.'.type'],$tudom,$tuname);
+ }
+ if (exists($$olddata{$altkey})) {
+ if (defined($data) && $$olddata{$altkey} ne $data) {
+ $haschange = 1;
+ }
+ } elsif ((!$reconlychg) && ($data ne '')) {
+ $haschange = 1;
+ }
+ $ustorekey = $tkeyrec;
+ } else {
+ if (exists($$olddata{$altkey})) {
+ if ($$olddata{$altkey} eq $data) {
+ $reconlychg = 1;
+ }
+ &Apache::lonnet::del('resourcedata',[$tkeyrec,$tkeyrec.'.type'],$tudom,$tuname);
+ }
+ if (exists($$olddata{$thiskey})) {
+ if (defined($data) && $$olddata{$thiskey} ne $data) {
+ $haschange = 1;
+ }
+ } elsif ((!$reconlychg) && ($data ne '')) {
+ $haschange = 1;
+ }
+ $ustorekey = $tkeynonrec;
+ }
+ } else {
+ if (exists($$olddata{$tkey})) {
+ if (defined($data) && $$olddata{$tkey} ne $data) {
+ $haschange = 1;
+ }
+ $ustorekey = $tkey;
+ }
+ }
+ if ($haschange || $reconlychg) {
+ unless ($env{'form.del_'.$thiskey}) {
+ if (&Apache::lonnet::put('resourcedata',{$ustorekey=>$data,
+ $ustorekey.'.type' => $typeof},
+ $tudom,$tuname) eq 'ok') {
+ &log_parmset({$ustorekey=>$data,$ustorekey.'.type' => $typeof},0,$tuname,$tudom);
+ $r->print(' '.$text.' '.
+ &Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print(''.
+ &mt('Error saving parameters').'
');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ }
+ }
+ } else {
+ if ($altkey) {
+ if ($recursive) {
+ if (exists($$olddata{$thiskey})) {
+ if ($$olddata{$thiskey} eq $data) {
+ $reconlychg = 1;
+ }
+ push(@delnonrec,($thiskey,$thiskey.'.type'));
+ }
+ if (exists($$olddata{$altkey})) {
+ if (defined($data) && $$olddata{$altkey} ne $data) {
+ $haschange = 1;
+ }
+ } elsif (($data ne '') && (!$reconlychg)) {
+ $haschange = 1;
+ }
+ $storekey = $altkey;
} else {
- $r->print(''.
- &mt('Error saving parameters').'
');
+ if (exists($$olddata{$altkey})) {
+ if ($$olddata{$altkey} eq $data) {
+ $reconlychg = 1;
+ }
+ push(@delrec,($altkey,$altkey.'.type'));
+ }
+ if (exists($$olddata{$thiskey})) {
+ if (defined($data) && $$olddata{$thiskey} ne $data) {
+ $haschange = 1;
+ }
+ } elsif (($data ne '') && (!$reconlychg)) {
+ $haschange = 1;
+ }
+ $storekey = $thiskey;
}
- &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
} else {
- $newdata{$thiskey}=$data;
- $newdata{$thiskey.'.type'}=$typeof;
+ if (defined($data) && $$olddata{$thiskey} ne $data) {
+ $haschange = 1;
+ $storekey = $thiskey;
+ }
+ }
+ }
+ if ($reconlychg || $haschange) {
+ unless ($env{'form.del_'.$thiskey}) {
+ $newdata{$storekey}=$data;
+ $newdata{$storekey.'.type'}=$typeof;
}
}
} elsif ($cmd eq 'del') {
if ($tuname) {
- if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>''},1,$tuname,$tudom);
- $r->print(' '.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ my $error;
+ if ($altkey) {
+ if (exists($$olddata{$altkey})) {
+ if (&Apache::lonnet::del('resourcedata',[$tkeyrec,$tkeyrec.'.type'],$tudom,$tuname) eq 'ok') {
+ &log_parmset({$tkeyrec=>''},1,$tuname,$tudom);
+ if ($recursive) {
+ $r->print(' '.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ }
+ } elsif ($recursive) {
+ $error = 1;
+ }
+ }
+ if (exists($$olddata{$thiskey})) {
+ if (&Apache::lonnet::del('resourcedata',[$tkeynonrec,$tkeynonrec.'.type'],$tudom,$tuname) eq 'ok') {
+ &log_parmset({$tkeynonrec=>''},1,$tuname,$tudom);
+ unless ($recursive) {
+ $r->print(' '.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ }
+ } elsif (!$recursive) {
+ $error = 1;
+ }
+ }
} else {
+ if (exists($$olddata{$thiskey})) {
+ if (&Apache::lonnet::del('resourcedata',[$tkey,$tkey.'.type'],$tudom,$tuname) eq 'ok') {
+ &log_parmset({$tkey=>''},1,$tuname,$tudom);
+ $r->print(' '.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $error = 1;
+ }
+ }
+ }
+ if ($error) {
$r->print(''.
&mt('Error deleting parameters').'
');
}
&Apache::lonnet::devalidateuserresdata($tuname,$tudom);
} else {
- push (@deldata,$thiskey,$thiskey.'.type');
+ if ($altkey) {
+ if (exists($$olddata{$altkey})) {
+ unless (grep(/^\Q$altkey\E$/,@delrec)) {
+ push(@deldata,($altkey,$altkey.'.type'));
+ }
+ }
+ if (exists($$olddata{$thiskey})) {
+ unless (grep(/^\Q$thiskey\E$/,@delnonrec)) {
+ push(@deldata,($thiskey,$thiskey.'.type'));
+ }
+ }
+ } elsif (exists($$olddata{$thiskey})) {
+ push(@deldata,($thiskey,$thiskey.'.type'));
+ }
}
}
}
}
# Store all course level
my $delentries=$#deldata+1;
+ my @alldels;
+ if (@delrec) {
+ push(@alldels,@delrec);
+ }
+ if (@delnonrec) {
+ push(@alldels,@delnonrec);
+ }
+ if (@deldata) {
+ push(@alldels,@deldata);
+ }
my @newdatakeys=keys(%newdata);
my $putentries=$#newdatakeys+1;
- if ($delentries) {
- if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
- my %loghash=map { $_ => '' } @deldata;
+ my ($delresult,$devalidate);
+ if (@alldels) {
+ if (&Apache::lonnet::del('resourcedata',\@alldels,$dom,$crs) eq 'ok') {
+ my %loghash=map { $_ => '' } @alldels;
&log_parmset(\%loghash,1);
- $r->print(''.&mt('Deleted [quant,_1,parameter]',$delentries/2).' ');
- } else {
+ if ($delentries) {
+ $r->print(''.&mt('Deleted [quant,_1,parameter]',$delentries/2).' ');
+ }
+ } elsif ($delentries) {
$r->print(''.
&mt('Error deleting parameters').'
');
}
- &Apache::lonnet::devalidatecourseresdata($crs,$dom);
+ $devalidate = 1;
}
if ($putentries) {
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
@@ -3819,6 +4035,9 @@ sub storedata {
$r->print(''.
&mt('Error saving parameters').'
');
}
+ $devalidate = 1;
+ }
+ if ($devalidate) {
&Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
}
@@ -3890,7 +4109,7 @@ sub listdata {
}
}
- foreach my $thiskey (sort {
+ foreach my $key (sort {
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
@@ -3930,8 +4149,8 @@ sub listdata {
$result;
- } keys(%{$listdata})) { # foreach my $thiskey
-
+ } keys(%{$listdata})) { # foreach my $key
+ my $thiskey = $key;
if ($$listdata{$thiskey.'.type'}) {
my $thistype=$$listdata{$thiskey.'.type'};
if ($$resourcedata{$thiskey.'.type'}) {
@@ -3940,6 +4159,7 @@ sub listdata {
my ($middle,$part,$name)=
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/);
my $section=&mt('All Students');
+ my $showval = $$resourcedata{$thiskey};
if ($middle=~/^\[(.*)\]/) {
my $issection=$1;
if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
@@ -3972,12 +4192,37 @@ sub listdata {
$middle=~s/\.+$//;
$middle=~s/^\.+//;
my $realm=''.&mt('All Resources').' ';
- if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) {
- my $mapurl = $1;
- my $maplevel = $2;
+ my ($is_map,$is_recursive,$mapurl,$maplevel);
+ if ($caller eq 'overview') {
+ if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) {
+ $mapurl = $1;
+ $maplevel = $2;
+ $is_map = 1;
+ }
+ } elsif ($caller eq 'newoverview') {
+ if ($middle=~/^(.+)\_\_\_\((all)\)$/) {
+ $mapurl = $1;
+ $maplevel = $2;
+ $is_map = 1;
+ }
+ }
+ if ($is_map) {
my $leveltitle = &mt('Folder/Map');
- if ($maplevel eq 'rec') {
- $leveltitle = &mt('Recursive');
+ unless (($name eq 'hiddenresource') || ($name eq 'encrypturl')) {
+ if ($caller eq 'newoverview') {
+ my $altkey = $thiskey;
+ $altkey =~ s/\Q___(all)\E/___(rec)/;
+ if ((exists($$resourcedata{$altkey})) & (!exists($$resourcedata{$thiskey}))) {
+ $is_recursive = 1;
+ if ($$resourcedata{$altkey.'.type'}) {
+ $thistype=$$resourcedata{$altkey.'.type'};
+ }
+ $showval = $$resourcedata{$altkey};
+ }
+ } elsif (($caller eq 'overview') && ($maplevel eq 'rec')) {
+ $thiskey =~ s/\Q___(rec)\E/___(all)/;
+ $is_recursive = 1;
+ }
}
$realm=''.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' ('.$mapurl.') ';
} elsif ($middle) {
@@ -4019,7 +4264,7 @@ sub listdata {
# Ready to print
#
my $parmitem = &standard_parameter_names($name);
- $r->print(&tablestart($readonly).
+ $r->print(&tablestart($readonly,$is_map).
&Apache::loncommon::start_data_table_row().
''.&mt($parmitem).
' ');
@@ -4039,30 +4284,48 @@ sub listdata {
$r->print(
&Apache::lonhtmlcommon::date_setter('parmform',
$jskey,
- $$resourcedata{$thiskey},
+ $showval,
'',1,$state));
unless ($readonly) {
$r->print(
' '.
- (($$resourcedata{$thiskey}!=0)?''.
+ (($showval!=0)?''.
&mt('Shift all dates based on this date').' ':'').
- &date_sanity_info($$resourcedata{$thiskey})
+ &date_sanity_info($showval)
);
}
} elsif ($thistype eq 'date_interval') {
$r->print(&date_interval_selector($thiskey,$name,
- $$resourcedata{$thiskey},$readonly));
+ $showval,$readonly));
} elsif ($thistype =~ m/^string/) {
$r->print(&string_selector($thistype,$thiskey,
- $$resourcedata{$thiskey},$name,$readonly));
+ $showval,$name,$readonly));
} else {
- $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
+ $r->print(&default_selector($thiskey,$showval,$readonly));
}
unless ($readonly) {
$r->print(' ');
}
- $r->print(' '.&Apache::loncommon::end_data_table_row());
+ $r->print('');
+ if ($is_map) {
+ if (($name eq 'encrypturl') || ($name eq 'hiddenresource')) {
+ $r->print(' ');
+ } else {
+ my ($disabled,$recon,$recoff);
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ if ($is_recursive) {
+ $recon = ' checked="checked"';
+ } else {
+ $recoff = ' checked="checked"';
+ }
+ $r->print(' ');
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table_row());
}
}
return $foundkeys;
@@ -4835,7 +5098,7 @@ ENDOVER
$r->print('');
$r->print('
');
- &displaymenu($r,\%allparms,\@pscat,\%keyorder); # FIXME: wrong parameters, could make keysindisplayorderCategory crash because $keyorder is undefined
+ &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);
@@ -4936,9 +5199,6 @@ sub secgroup_lister {
my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
$$listdata{$newparmkey}=1;
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
- $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(rec).'.$part.'.'.$cat;
- $$listdata{$newparmkey}=1;
- $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
}
} else {
# resource-level parameter
@@ -5084,10 +5344,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') {
@@ -5194,8 +5452,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/^\[(.*)\]//;
}
@@ -5589,16 +5846,17 @@ sub addmetafield {
$r->print('You may undelete previously deleted fields. Check those you wish to undelete and click Undelete. ');
$r->print('');
}
- $r->print('
Or you may enter a new metadata field name.');
}
- $r->print('');
&endSettingsScreen($r);
}
@@ -5921,17 +6179,13 @@ ENDYESNO
# $issection - section or group name
# $realmdescription - title for the parameter level and resource (without using HTML)
#
-# FIXME: remove unused fields.
-#
# @param {string} $key - parameter log key
# @param {string} $uname - user name
# @param {string} $udom - user domain
-# @param {string} $exeuser - unused
-# @param {string} $exedomain - unused
# @param {boolean} $typeflag - .type log entry
# @returns {Array}
sub components {
- my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
+ my ($key,$uname,$udom,$typeflag)=@_;
if ($typeflag) {
$key=~s/\.type$//;
@@ -5998,6 +6252,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';
}
# Returns a parameter title for standard parameters, the name for others.
@@ -6145,7 +6400,7 @@ sub parm_change_log {
my $typeflag = ($changed =~/\.type$/ &&
!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);
+ &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},$typeflag);
if ($env{'request.course.sec'} ne '') {
next if (($issection ne '') && ($issection ne $env{'request.course.sec'}));
if ($uname ne '') {