--- loncom/interface/lonparmset.pm 2016/08/10 21:05:42 1.566
+++ loncom/interface/lonparmset.pm 2017/07/13 13:57:48 1.577
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.566 2016/08/10 21:05:42 damieng Exp $
+# $Id: lonparmset.pm,v 1.577 2017/07/13 13:57:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1380,9 +1380,11 @@ ENDHEAD
# @param {string} $cgroup - group name
# @param {array reference} $usersgroups - list of groups the user belongs to, if any
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
+# @param {boolean} $readonly - true if no editing allowed.
sub print_row {
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
- $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp)=@_;
+ $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp,
+ $readonly)=@_;
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
@@ -1427,27 +1429,27 @@ sub print_row {
if ($parmlev eq 'general') {
if ($uname) {
- &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
} elsif ($csec) {
- &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &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);
} elsif ($csec) {
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} else {
if ($uname) {
@@ -1467,35 +1469,35 @@ sub print_row {
}
}
- &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &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,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);
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &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,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
if ($cgroup) {
- &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &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,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly);
}
if ($uname) {
if ($othergrp) {
$r->print($othergrp);
}
- &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &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,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} # end of $parmlev if/else
@@ -1532,31 +1534,40 @@ sub print_row {
# @param {array reference} $typeoutpar - array level -> parameter type (when defined)
# @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.
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_;
$r->print('
');
my $nolink = 0;
- if ($which == 14 || $which == 15) {
- $nolink = 1;
- } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
+ if ($readonly) {
$nolink = 1;
- } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) {
- if ($noeditgrp) {
- $nolink = 1;
- }
- } elsif ($mprefix =~ /availablestudent\&$/) {
- if ($which > 4) {
+ } else {
+ if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&/) {
$nolink = 1;
- }
- } elsif ($mprefix =~ /examcode\&$/) {
- unless ($which == 2) {
+ } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
$nolink = 1;
+ } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) {
+ if ($noeditgrp) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /availablestudent\&$/) {
+ if ($which > 4) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /examcode\&$/) {
+ unless ($which == 2) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /(encrypturl|hiddenresource)/) {
+ if ($which == 16 || $which == 10 || $which == 6 || $which == 2) {
+ $nolink = 1;
+ }
}
}
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($$outpar[$which],$$typeoutpar[$which],$parmname));
} else {
$r->print(&plink($$typeoutpar[$which],
$$display{$value},$$outpar[$which],
@@ -1928,7 +1939,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.
@@ -2022,6 +2033,7 @@ sub parmboxes {
$r->print(' '
.' '.&mt($categories{$key}).''."\n");
foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
+ next if ($tempkey eq '');
$r->print(''
.''
@@ -3491,8 +3510,9 @@ ENDMAPONE
foreach my $item (&keysinorder(\%name,\%keyorder)) {
$r->print(&Apache::loncommon::start_data_table_row());
&print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default,
- \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
- $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp);
+ \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
+ $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
+ $readonly);
}
$r->print(&Apache::loncommon::end_data_table()
.''
@@ -3517,7 +3537,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 {
@@ -3526,7 +3546,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;
@@ -3605,6 +3629,8 @@ sub storedata {
my %newdata=();
undef %newdata;
my @deldata=();
+ my @delrec=();
+ my @delnonrec=();
undef @deldata;
my ($got_chostname,$chostname,$cmajor,$cminor);
my $now = time;
@@ -3612,11 +3638,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);
@@ -3700,7 +3742,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 '')) {
@@ -3747,54 +3789,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') {
@@ -3804,6 +3987,9 @@ sub storedata {
$r->print(''.
&mt('Error saving parameters').'
');
}
+ $devalidate = 1;
+ }
+ if ($devalidate) {
&Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
}
@@ -3850,9 +4036,10 @@ sub parse_listdata_key {
# @param {string} $sortorder - realmstudent|studentrealm
# @param {string} $caller - name of the calling sub (overview|newoverview)
# @param {hash reference} $classlist - from loncoursedata::get_classlist
+# @param {boolean} $readonly - true if editing not allowed
# @returns{integer} - number of $listdata parameters processed
sub listdata {
- my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist)=@_;
+ my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_;
# Start list output
@@ -3874,7 +4061,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);
@@ -3914,17 +4101,17 @@ sub listdata {
$result;
- } keys(%{$listdata})) { # foreach my $thiskey
-
- my $readonly;
+ } keys(%{$listdata})) { # foreach my $key
+ my $thiskey = $key;
if ($$listdata{$thiskey.'.type'}) {
my $thistype=$$listdata{$thiskey.'.type'};
if ($$resourcedata{$thiskey.'.type'}) {
$thistype=$$resourcedata{$thiskey.'.type'};
}
my ($middle,$part,$name)=
- ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ ($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)/) {
@@ -3957,12 +4144,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) {
@@ -4004,7 +4216,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).
' | ');
@@ -4024,30 +4236,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;
@@ -4140,7 +4370,7 @@ sub string_ip_selector {
@{$access{'deny'}} = ('');
}
my ($disabled,$addmore);
- if ($disabled) {
+ if ($readonly) {
$disabled=' disabled="disabled"';
} else {
$addmore = "\n".'';
@@ -4561,17 +4791,21 @@ sub date_interval_selector {
$currprocdisplay = 'text';
}
my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
$result .= '
'.&mt('Include "done" button').
- '
'.
+ 'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'"'.$disabled.' />
'.
''.&mt('Button text').': '.
- '&').'" />';
+ '&').'"'.$disabled.' />';
}
}
unless ($readonly) {
@@ -4705,11 +4939,15 @@ sub dateshift {
#
# @param {Apache2::RequestRec} $r - the Apache request
sub newoverview {
- my ($r) = @_;
+ 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 $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
@@ -4868,11 +5106,13 @@ ENDOVER
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview');
+ &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
+ }
+ $r->print(&tableend());
+ unless ($readonly) {
+ $r->print( ((($env{'form.store'}) || ($env{'form.dis'}))?'':'') );
}
- $r->print(&tableend().
- ((($env{'form.store'}) || ($env{'form.dis'}))?'':'').
- '');
+ $r->print('');
&endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
@@ -4911,9 +5151,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
@@ -4934,10 +5171,14 @@ sub secgroup_lister {
#
# @param {Apache2::RequestRec} $r - the Apache request
sub overview {
- my ($r) = @_;
+ 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 $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
my $js = '