--- loncom/interface/lonparmset.pm 2017/07/13 13:57:48 1.577
+++ loncom/interface/lonparmset.pm 2017/07/15 02:31:33 1.579
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.577 2017/07/13 13:57:48 raeburn Exp $
+# $Id: lonparmset.pm,v 1.579 2017/07/15 02:31:33 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,
@@ -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,17 +1487,13 @@ 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) {
@@ -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 || $mprefix =~ /mapalias\&/) {
+ if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&$/) {
$nolink = 1;
} elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
$nolink = 1;
@@ -1559,19 +1626,15 @@ sub print_td {
unless ($which == 2) {
$nolink = 1;
}
- } elsif ($mprefix =~ /(encrypturl|hiddenresource)/) {
- if ($which == 16 || $which == 10 || $which == 6 || $which == 2) {
- $nolink = 1;
- }
}
}
if ($nolink) {
my ($parmname)=((split(/\&/,$mprefix))[1]=~/\_([^\_]+)$/);
- $r->print(&valout($$outpar[$which],$$typeoutpar[$which],$parmname));
+ $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");
}
@@ -3119,10 +3182,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());
@@ -3152,44 +3215,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('
');
@@ -3410,8 +3472,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()
);
---|