[LON-CAPA-cvs] cvs: modules /gerd lonparmset.pm loncom/interface lonparmset.pm loncom/publisher packages.tab
www
lon-capa-cvs@mail.lon-capa.org
Sat, 04 Jun 2005 17:35:22 -0000
This is a MIME encoded message
--www1117906522
Content-Type: text/plain
www Sat Jun 4 13:35:22 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
/loncom/publisher packages.tab
/modules/gerd lonparmset.pm
Log:
Just saving my work ... nothing good here.
--www1117906522
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050604133522.txt"
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.207 loncom/interface/lonparmset.pm:1.208
--- loncom/interface/lonparmset.pm:1.207 Sat Jun 4 11:26:13 2005
+++ loncom/interface/lonparmset.pm Sat Jun 4 13:35:19 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.207 2005/06/04 15:26:13 www Exp $
+# $Id: lonparmset.pm,v 1.208 2005/06/04 17:35:19 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -766,6 +766,87 @@
}
}
+
+##################################################
+##################################################
+
+sub parmmenu {
+ my ($r,$allparms,$pscat)=@_;
+ my $tempkey;
+ $r->print(<<ENDSCRIPT);
+<script type="text/javascript">
+ function checkall(value, checkName) {
+ for (i=0; i<document.forms.parmform.elements.length; i++) {
+ ele = document.forms.parmform.elements[i];
+ if (ele.name == checkName) {
+ document.forms.parmform.elements[i].checked=value;
+ }
+ }
+ }
+</script>
+ENDSCRIPT
+ $r->print(&mt('Select Parameters to View'));
+ $r->print("\n<table><tr>");
+ my $cnt=0;
+ foreach $tempkey (sort { $$allparms{$a} cmp $$allparms{$b} }
+ keys %{$allparms} ) {
+ ++$cnt;
+ $r->print("</tr>\n<tr>") if ($cnt%2);
+ $r->print("\n<td><input type='checkbox' name='pscat' ");
+ $r->print('value="'.$tempkey.'"');
+ if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
+ $r->print(' checked');
+ }
+ $r->print('>'.$$allparms{$tempkey}.'</td>');
+ }
+ $r->print('
+</tr><tr><td>
+<input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
+</td><td>
+<input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
+</td>
+');
+ $r->print('</tr></table>');
+}
+
+sub menu {
+ my ($r,$allparms,$allparts,$allkeys,$pscat,$psprt,$fcat)=@_;
+ my $tempkey;
+
+ &parmmenu($r,$allkeys,$pscat);
+
+ $r->print('<table><tr>');
+ $r->print('<td><select multiple name="psprt" size="5">');
+ $r->print('<option value="all"');
+ $r->print(' selected') unless (@{$psprt});
+ $r->print('>'.&mt('All Parts').'</option>');
+ my %temphash=();
+ foreach (@{$psprt}) { $temphash{$_}=1; }
+ foreach $tempkey (sort keys %{$allparts}) {
+ unless ($tempkey =~ /\./) {
+ $r->print('<option value="'.$tempkey.'"');
+ if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
+ $r->print(' selected');
+ }
+ $r->print('>'.$$allparts{$tempkey}.'</option>');
+ }
+ }
+ $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
+
+ $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
+ $r->print('<select name="fcat">');
+ $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
+ foreach (sort keys %{$allkeys}) {
+ $r->print('<option value="'.$_.'"');
+ if ($fcat eq $_) { $r->print(' selected'); }
+ $r->print('>'.$$allkeys{$_}.'</option>');
+ }
+ $r->print('</select></td>');
+
+ $r->print('</tr><tr><td colspan="3"><hr /></td></tr></table>');
+
+}
+
##################################################
##################################################
@@ -848,7 +929,6 @@
my $pschp=$env{'form.pschp'};
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
if (!@psprt) { $psprt[0]='0'; }
- my $showoptions=$env{'form.showoptions'};
my $pssymb='';
my $parmlev='';
@@ -1006,112 +1086,16 @@
} else {
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
$r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
- $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
+ $r->print('<td><input type="hidden" value="'.
+ $pssymb.'" name="symb"><input type="submit" name="dis" value="'.
+ $submitmessage.'"></td>');
$r->print('</tr>');
- $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
- }
-
- $r->print('<tr><td colspan="3"><hr /><label><input type="checkbox"');
- if ($showoptions eq 'show') {$r->print(" checked ");}
- $r->print(' name="showoptions" value="show" />'.&mt('Show More Options').'</label><hr /></td></tr>');
-# $r->print("<tr><td>Show: $showoptions</td></tr>");
-# $r->print("<tr><td>pscat: @pscat</td></tr>");
-# $r->print("<tr><td>psprt: @psprt</td></tr>");
-# $r->print("<tr><td>fcat: $fcat</td></tr>");
-
- if ($showoptions eq 'show') {
- my $tempkey;
-
- $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
-
- $r->print('<tr><td colspan="2"><table><tr>');
- my $cnt=0;
- foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
- keys %allparms ) {
- ++$cnt;
- $r->print('</tr><tr>') if ($cnt%2);
- $r->print('<td><input type="checkbox" name="pscat" ');
- $r->print('value="'.$tempkey.'"');
- if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
- $r->print(' checked');
- }
- $r->print('>'.$allparms{$tempkey}.'</td>');
- }
- $r->print('
-</tr><tr><td>
-<script type="text/javascript">
- function checkall(value, checkName) {
- for (i=0; i<document.forms.parmform.elements.length; i++) {
- ele = document.forms.parmform.elements[i];
- if (ele.name == checkName) {
- document.forms.parmform.elements[i].checked=value;
- }
- }
}
-</script>
-<input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
-</td><td>
-<input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
-</td>
-');
- $r->print('</tr></table>');
-
-# $r->print('<tr><td>Select Parts</td><td>');
- $r->print('<td><select multiple name="psprt" size="5">');
- $r->print('<option value="all"');
- $r->print(' selected') unless (@psprt);
- $r->print('>'.&mt('All Parts').'</option>');
- my %temphash=();
- foreach (@psprt) { $temphash{$_}=1; }
- foreach $tempkey (sort keys %allparts) {
- unless ($tempkey =~ /\./) {
- $r->print('<option value="'.$tempkey.'"');
- if ($psprt[0] eq "all" || $temphash{$tempkey}) {
- $r->print(' selected');
- }
- $r->print('>'.$allparts{$tempkey}.'</option>');
- }
- }
- $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
-
- $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
- $r->print('<select name="fcat">');
- $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
- foreach (sort keys %allkeys) {
- $r->print('<option value="'.$_.'"');
- if ($fcat eq $_) { $r->print(' selected'); }
- $r->print('>'.$allkeys{$_}.'</option>');
- }
- $r->print('</select></td>');
-
- $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
-
- } else { # hide options - include any necessary extras here
-
- $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
+ $r->print('</table><br />');
- unless (@pscat) {
- foreach (keys %allparms ) {
- $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
- }
- } else {
- foreach (@pscat) {
- $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
- }
- }
- unless (@psprt) {
- foreach (keys %allparts ) {
- $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
- }
- } else {
- foreach (@psprt) {
- $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
- }
- }
+ &menu($r,\%allparms,\%allparts,\%allkeys,\@pscat,\@psprt,$fcat);
- }
- $r->print('</table><br />');
if (($prevvisit) || ($pschp) || ($pssymb)) {
$submitmessage = &mt("Update Course Assessment Parameter Display");
} else {
@@ -1119,13 +1103,6 @@
}
$r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
-# my @temp_psprt;
-# foreach my $t (@psprt) {
-# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
-# }
-
-# @psprt = @temp_psprt;
-
my @temp_pscat;
map {
my $cat = $_;
@@ -1852,30 +1829,11 @@
return $resourcedata;
}
-sub extractuser {
- my $key=shift;
- return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
-}
-sub overview {
- my $r=shift;
- my $bodytag=&Apache::loncommon::bodytag(
- 'Set/Modify Course Assessment Parameters');
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
- my $html=&Apache::lonxml::xmlbegin();
- $r->print(<<ENDOVER);
-$html
-<head>
-<title>LON-CAPA Course Environment</title>
-</head>
-$bodytag
-$breadcrumbs
-<form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
-<input type="hidden" name="overview" value="1" />
-ENDOVER
# Setting
+
+sub storedata {
+ my ($r,$crs,$dom)=@_;
# Set userlevel immediately
# Do an intermediate store of course level
my $olddata=&readdata($crs,$dom);
@@ -1960,10 +1918,15 @@
}
&Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
-# Read modified data
+}
- my $resourcedata=&readdata($crs,$dom);
+sub extractuser {
+ my $key=shift;
+ return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
+}
+sub listdata {
+ my ($r,$resourcedata,$listdata)=@_;
# Start list output
my $oldsection='';
@@ -1972,7 +1935,7 @@
my $pointer=0;
$tableopen=0;
my $foundkeys=0;
- foreach my $thiskey (sort keys %{$resourcedata}) {
+ foreach my $thiskey (sort keys %{$listdata}) {
if ($$resourcedata{$thiskey.'.type'}) {
my ($middle,$part,$name)=
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
@@ -2034,9 +1997,61 @@
$r->print('</td></tr>');
}
}
-
+ return $foundkeys;
+}
+
+sub newoverview {
+ my $r=shift;
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Set Course Assessment Parameters');
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print(<<ENDOVER);
+$html
+<head>
+<title>LON-CAPA Parameters</title>
+</head>
+$bodytag
+$breadcrumbs
+<form method="post" action="/adm/parmset?action=newoverview" name="overviewform">
+ENDOVER
+ $r->print(&tableend().
+ '<p><input type="submit" value="'.&mt('Submit').'" /></p></form></body></html>');
+}
+
+sub overview {
+ my $r=shift;
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Modify Course Assessment Parameters');
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print(<<ENDOVER);
+$html
+<head>
+<title>LON-CAPA Parameters</title>
+</head>
+$bodytag
+$breadcrumbs
+<form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
+ENDOVER
+# Store modified
+
+ &storedata($r,$crs,$dom);
+
+# Read modified data
+
+ my $resourcedata=&readdata($crs,$dom);
+
+# List data
+
+ my $foundkeys=&listdata($r,$resourcedata,$resourcedata);
+
$r->print(&tableend().'<p>'.
- ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
+ ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>');
}
##################################################
@@ -2174,6 +2189,10 @@
{ text => 'Modify Course Assessment Parameters - Overview Mode',
action => 'setoverview',
permission => $parm_permission,
+ },
+ { text => 'Set Course Assessment Parameters - Overview Mode',
+ action => 'newoverview',
+ permission => $parm_permission,
},
{ text => 'Set/Modify Course Assessment Parameters - Table Mode',
action => 'settable',
@@ -2286,6 +2305,10 @@
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
&overview($r);
+ } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
+ text=>"Overview Mode"});
+ &newoverview($r);
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
text=>"Table Mode",
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.44 loncom/publisher/packages.tab:1.45
--- loncom/publisher/packages.tab:1.44 Sat Jun 4 04:15:10 2005
+++ loncom/publisher/packages.tab Sat Jun 4 13:35:19 2005
@@ -28,7 +28,7 @@
part&display&type:string
part&ordered&type:string_yesno
part&ordered&default:no
-part&ordered&display:Show Parts 1 at a time
+part&ordered&display:Show Parts One-at-a-Time
part_0&hiddenparts&display:List of hidden parts
part_0&hiddenparts&type:string_any
part_0&hiddenresource&display:Resource hidden from students
Index: modules/gerd/lonparmset.pm
diff -u modules/gerd/lonparmset.pm:1.1 modules/gerd/lonparmset.pm:1.2
--- modules/gerd/lonparmset.pm:1.1 Tue May 31 11:45:32 2005
+++ modules/gerd/lonparmset.pm Sat Jun 4 13:35:19 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.1 2005/05/31 15:45:32 www Exp $
+# $Id: lonparmset.pm,v 1.2 2005/06/04 17:35:19 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,20 +62,16 @@
use Apache::lonhomework;
use Apache::lonxml;
use Apache::lonlocal;
+use Apache::lonnavmaps;
+# --- Caches local to lonparmset
-my @symbs;
-my %typep;
-my %keyp;
-
-my %maptitles;
-
-# Caches local to lonnavmaps
-
-my %courseopt=();
-my $courseoptkey='';
-my %useropt=();
-my $useroptkey='';
+my $parmhashid;
+my %parmhash;
+my $symbsid;
+my %symbs;
+
+# --- end local caches
##################################################
##################################################
@@ -107,13 +103,27 @@
=cut
##################################################
-##################################################
sub parmval {
+ my ($what,$id,$def,$uname,$udom,$csec)=@_;
+ return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec);
+}
+
+sub parmval_by_symb {
my ($what,$symb,$def,$uname,$udom,$csec)=@_;
+# load caches
+
+ &cacheparmhash();
+
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
+ my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
+
+
my $result='';
my @outpar=();
# ----------------------------------------------------- Cascading lookup scheme
- my $map=(&Apache::lonnet::decode_symb($symb))[0];
+ my $map=(&Apache::lonnet::decode_symb($symb))[0];
my $symbparm=$symb.'.'.$what;
my $mapparm=$map.'___(all).'.$what;
@@ -126,32 +136,17 @@
my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
-# -------------------------------------------------------------- Get coursedata
- unless ($courseoptkey eq $env{'request.course.id'}) {
- %courseopt = &Apache::lonnet::dump
- ('resourcedata',
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- $courseoptkey=$env{'request.course.id'};
- }
-# --------------------------------------------------- Get userdata (if present)
- if ($uname) {
- unless ($useroptkey eq $uname.'@'.$udom) {
- %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
- $useroptkey=$uname.'@'.$udom;
- }
- } else {
- %useropt=();
- }
+
+
# --------------------------------------------------------- first, check course
- if (defined($courseopt{$courselevel})) {
- $outpar[11]=$courseopt{$courselevel};
+ if (defined($$courseopt{$courselevel})) {
+ $outpar[11]=$$courseopt{$courselevel};
$result=11;
}
- if (defined($courseopt{$courselevelm})) {
- $outpar[10]=$courseopt{$courselevelm};
+ if (defined($$courseopt{$courselevelm})) {
+ $outpar[10]=$$courseopt{$courselevelm};
$result=10;
}
@@ -164,24 +159,24 @@
my $thisparm=$parmhash{$symbparm};
if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
- if (defined($courseopt{$courselevelr})) {
- $outpar[7]=$courseopt{$courselevelr};
+ if (defined($$courseopt{$courselevelr})) {
+ $outpar[7]=$$courseopt{$courselevelr};
$result=7;
}
# ------------------------------------------------------ fourth, back to course
if (defined($csec)) {
- if (defined($courseopt{$seclevel})) {
- $outpar[6]=$courseopt{$seclevel};
+ if (defined($$courseopt{$seclevel})) {
+ $outpar[6]=$$courseopt{$seclevel};
$result=6;
}
- if (defined($courseopt{$seclevelm})) {
- $outpar[5]=$courseopt{$seclevelm};
+ if (defined($$courseopt{$seclevelm})) {
+ $outpar[5]=$$courseopt{$seclevelm};
$result=5;
}
- if (defined($courseopt{$seclevelr})) {
- $outpar[4]=$courseopt{$seclevelr};
+ if (defined($$courseopt{$seclevelr})) {
+ $outpar[4]=$$courseopt{$seclevelr};
$result=4;
}
}
@@ -189,29 +184,66 @@
# ---------------------------------------------------------- fifth, check user
if (defined($uname)) {
- if (defined($useropt{$courselevel})) {
- $outpar[3]=$useropt{$courselevel};
+ if (defined($$useropt{$courselevel})) {
+ $outpar[3]=$$useropt{$courselevel};
$result=3;
}
- if (defined($useropt{$courselevelm})) {
- $outpar[2]=$useropt{$courselevelm};
+ if (defined($$useropt{$courselevelm})) {
+ $outpar[2]=$$useropt{$courselevelm};
$result=2;
}
- if (defined($useropt{$courselevelr})) {
- $outpar[1]=$useropt{$courselevelr};
+ if (defined($$useropt{$courselevelr})) {
+ $outpar[1]=$$useropt{$courselevelr};
$result=1;
}
}
return ($result,@outpar);
}
+sub resetparmhash {
+ $parmhashid='';
+}
+
+sub cacheparmhash {
+ if ($parmhashid eq $env{'request.course.fn'}) { return; }
+ my %parmhashfile;
+ if (tie(%parmhashfile,'GDBM_File',
+ $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
+ %parmhash=%parmhashfile;
+ untie %parmhashfile;
+ $parmhashid=$env{'request.course.fn'};
+ }
+}
+
+sub resetsymbcache {
+ $symbsid='';
+}
+
+sub symbcache {
+ my $id=shift;
+ if ($symbsid ne $env{'request.course.id'}) {
+ %symbs=();
+ }
+ unless ($symbs{$id}) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if ($id=~/\./) {
+ my $resource=$navmap->getById($id);
+ $symbs{$id}=$resource->symb();
+ } else {
+ my $resource=$navmap->getByMapPc($id);
+ $symbs{$id}=&Apache::lonnet::declutter($resource->src());
+ }
+ $symbsid=$env{'request.course.id'};
+ }
+ return $symbs{$id};
+}
##################################################
##################################################
#
-# Store a parameter
+# Store a parameter by ID
#
# Takes
# - resource id
@@ -223,15 +255,31 @@
# - userdomain
sub storeparm {
+ my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
+ &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
+}
+
+#
+# Store a parameter by symb
+#
+# Takes
+# - symb
+# - name of parameter
+# - level
+# - new value
+# - new type
+# - username
+# - userdomain
+
+sub storeparm_by_symb {
+# ---------------------------------------------------------- Get symb, map, etc
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
- $spnam=~s/\_([^\_]+)$/\.$1/;
# ---------------------------------------------------------- Construct prefixes
- my $map=(&Apache::lonnet::decode_symb($symb))[0];
-
+ $spnam=~s/\_([^\_]+)$/\.$1/;
+ my $map=(&Apache::lonnet::decode_symb($symb))[0];
my $symbparm=$symb.'.'.$spnam;
-
my $mapparm=$map.'___(all).'.$spnam;
-
+
my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
@@ -256,8 +304,9 @@
if ($snum>3) {
# ---------------------------------------------------------------- Store Course
#
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
# Expire sheets
- $courseoptkey='';
&Apache::lonnet::expirespread('','','studentcalc');
if (($snum==7) || ($snum==4)) {
&Apache::lonnet::expirespread('','','assesscalc',$symb);
@@ -269,20 +318,16 @@
# Store parameter
if ($delete) {
$reply=&Apache::lonnet::del
- ('resourcedata',[keys(%storecontent)],
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
+ ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
} else {
$reply=&Apache::lonnet::cput
- ('resourcedata',\%storecontent,
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
+ ('resourcedata',\%storecontent,$cdom,$cnum);
}
+ &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
} else {
# ------------------------------------------------------------------ Store User
#
# Expire sheets
- $useroptkey='';
&Apache::lonnet::expirespread($uname,$udom,'studentcalc');
if ($snum==1) {
&Apache::lonnet::expirespread
@@ -401,33 +446,23 @@
&valout($value,$type).'</a><a name="'.$marker.'"></a>';
}
-
sub startpage {
- my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;
+ my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_;
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
'onUnload="pclose()"');
- my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
&Apache::loncommon::selectstudent_link('parmform','uname','udom');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my %lt=&Apache::lonlocal::texthash(
- 'cep' => "Course Environment Parameters",
- 'scep' => "Set Course Environment Parameters",
- 'smcap' => "Set/Modify Course Assessment Parameter",
- 'mcap' => "Modify Course Assessment Parameters",
- 'caphm' => "Course Assessment Parameter - Helper Mode",
- 'capom' => "Course Assessment Parameters - Overview Mode",
'captm' => "Course Assessments Parameters - Table Mode",
'sg' => "Section/Group",
'fu' => "For User",
'oi' => "or ID",
'ad' => "at Domain"
);
- my $overallhelp=
- &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface');
- my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters");
my $html=&Apache::lonxml::xmlbegin();
$r->print(<<ENDHEAD);
$html
@@ -478,28 +513,7 @@
</head>
$bodytag
$breadcrumbs
-$overallhelp
ENDHEAD
-
- unless ($trimheader) {$r->print(<<ENDHEAD2);
-<form method="post" action="/adm/parmset" name="envform">
-<h4>$lt{'cep'}</h4>
-<input type="submit" name="crsenv" value="$lt{'scep'}" />
-</form>
-<hr />
-$assessparmhelp
-<form method="post" action="/adm/helper/parameter.helper" name="helpform">
-<h4>$lt{'caphm'}</h4>
-<input type="submit" value="$lt{'smcap'}" />
-</form>
-<hr />
-<form method="post" action="/adm/parmset" name="overview">
-<h4>$lt{'capom'}</h4>
-<input type="submit" name="overview" value="$lt{'mcap'}" />
-</form>
-<hr />
-ENDHEAD2
- }
my %sectionhash=();
my $sections='';
if (&Apache::loncommon::get_sections(
@@ -518,8 +532,8 @@
<h4>$lt{'captm'}</h4>
ENDHEAD3
- if (!$have_assesments) {
- $r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />');
+ if (!$have_assessments) {
+ $r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />');
} else {
$r->print(<<ENDHEAD);
<b>
@@ -540,17 +554,17 @@
}
sub print_row {
- my ($r,$which,$part,$name,$symb,$default,$defaulttype,$display,$defbgone,
+ my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
$defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
# get the values for the parameter in cascading order
# empty levels will remain empty
my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
- $symb,$$default{$which},$uname,$udom,$csec);
+ $rid,$$default{$which},$uname,$udom,$csec);
# get the type for the parameters
# problem: these may not be set for all levels
my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
$$name{$which}.'.type',
- $symb,$$defaulttype{$which},$uname,$udom,$csec);
+ $rid,$$defaulttype{$which},$uname,$udom,$csec);
# cascade down manually
my $cascadetype=$$defaulttype{$which};
for (my $i=11;$i>0;$i--) {
@@ -562,7 +576,7 @@
}
my $parm=$$display{$which};
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
$r->print('<td bgcolor='.$defbgtwo.' align="center">'
.$$part{$which}.'</td>');
} else {
@@ -573,7 +587,7 @@
my $thismarker=$which;
$thismarker=~s/^parameter\_//;
- my $mprefix=$symb.'&'.$thismarker.'&';
+ my $mprefix=$rid.'&'.$thismarker.'&';
if ($parmlev eq 'general') {
@@ -597,42 +611,30 @@
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- if ($parmlev eq 'brief') {
-
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
-
- if ($csec) {
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- if ($uname) {
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- } else {
-
- &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+
+ if ($csec) {
+ &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ }
+ if ($uname) {
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ }
- if ($csec) {
- &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- } # end of $brief if/else
} # end of $parmlev if/else
$r->print('<td bgcolor=#CCCCFF align="center">'.
&valout($outpar[$result],$typeoutpar[$result]).'</td>');
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
- '.'.$$name{$which},$symb);
+ '.'.$$name{$which},$$symbp{$rid});
my $sessionvaltype=$typeoutpar[$result];
if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
$r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
@@ -658,25 +660,111 @@
}
-# This prints out one resource in table format
+=pod
-sub one_resource_entry {
- my ($resource,$onlyparts,$onlyparms)=@_;
- my $symb=$resource->symb();
+=item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
+Input: See list below:
+=over 4
-}
+=item B<ids>: An array that will contain all of the ids in the course.
-# This prints out all resources in table format
+=item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
+=item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
+
+=item B<allparms>: hash, name of parameter->display value (what is the display value?)
+
+=item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
+
+=item B<allkeys>: hash, full key to part->display value (what's display value?)
+
+=item B<allmaps>: hash, ???
+
+=item B<fcat>: ???
+
+=item B<defp>: hash, ???
+
+=item B<mapp>: ??
+
+=item B<symbp>: hash, id->full sym?
+
+=back
+
+=cut
+
+sub extractResourceInformation {
+ my $ids = shift;
+ my $typep = shift;
+ my $keyp = shift;
+ my $allparms = shift;
+ my $allparts = shift;
+ my $allkeys = shift;
+ my $allmaps = shift;
+ my $fcat = shift;
+ my $defp = shift;
+ my $mapp = shift;
+ my $symbp = shift;
+ my $maptitles=shift;
+ my $uris=shift;
my $navmap = Apache::lonnavmaps::navmap->new();
my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
foreach my $resource (@allres) {
- my $symb=$resource->symb();
+ my $id=$resource->id();
+ my ($mapid,$resid)=split(/\./,$id);
+ if ($mapid eq '0') { next; }
+ $$ids[$#$ids+1]=$id;
+ my $srcf=$resource->src();
+ $srcf=~/\.(\w+)$/;
+ $$typep{$id}=$1;
+ $$keyp{$id}='';
+ $$uris{$id}=$srcf;
+ foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+ if ($_=~/^parameter\_(.*)/) {
+ my $key=$_;
+ my $allkey=$1;
+ $allkey=~s/\_/\./g;
+ if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq
+ 'parm') {
+ next; #hide hidden things
+ }
+ my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+ my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+ my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ my $parmdis = $display;
+ $parmdis =~ s|(\[Part.*)$||g;
+ my $partkey = $part;
+ $partkey =~ tr|_|.|;
+ $$allparms{$name} = $parmdis;
+ $$allparts{$part} = "[Part $part]";
+ $$allkeys{$allkey}=$display;
+ if ($allkey eq $fcat) {
+ $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
+ }
+ if ($$keyp{$id}) {
+ $$keyp{$id}.=','.$key;
+ } else {
+ $$keyp{$id}=$key;
+ }
+ }
+ }
+ $$mapp{$id}=
+ &Apache::lonnet::declutter($resource->enclosing_map_src());
+ $$mapp{$mapid}=$$mapp{$id};
+ $$allmaps{$mapid}=$$mapp{$id};
+ if ($mapid eq '1') {
+ $$maptitles{$mapid}='Main Course Documents';
+ } else {
+ $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+ }
+ $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
+ $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
+ $$symbp{$mapid}=$$mapp{$id}.'___(all)';
}
+}
##################################################
##################################################
@@ -711,6 +799,15 @@
sub assessparms {
my $r=shift;
+
+ my @ids=();
+ my %symbp=();
+ my %mapp=();
+ my %typep=();
+ my %keyp=();
+ my %uris=();
+ my %maptitles=();
+
# -------------------------------------------------------- Variable declaration
my %allkeys=();
my %allmaps=();
@@ -732,6 +829,8 @@
my %defp;
+ @ids=();
+ %symbp=();
%typep=();
my $message='';
@@ -753,7 +852,6 @@
my $pssymb='';
my $parmlev='';
- my $trimheader='';
my $prevvisit=$env{'form.prevvisit'};
unless ($env{'form.parmlev'}) {
@@ -772,13 +870,11 @@
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
- $trimheader='yes';
} elsif ($env{'form.symb'}) {
$pssymb=$env{'form.symb'};
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
- $trimheader='yes';
} else {
$env{'form.url'}='';
}
@@ -829,38 +925,47 @@
my $fcat=$env{'form.fcat'};
unless ($fcat) { $fcat=''; }
+
+# --------------------------------------------------------- Get all assessments
+ &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
+
+ $mapp{'0.0'} = '';
+ $symbp{'0.0'} = '';
+
# ---------------------------------------------------------- Anything to store?
if ($env{'form.pres_marker'}) {
- $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
- $env{'form.pres_value'},
- $env{'form.pres_type'},
- $uname,$udom,$csec);
+ my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
+ my @values=split(/\&\&\&/,$env{'form.pres_value'});
+ my @types=split(/\&\&\&/,$env{'form.pres_type'});
+ for (my $i=0;$i<=$#markers;$i++) {
+ $message.=&storeparm(split(/\&/,$markers[$i]),
+ $values[$i],
+ $types[$i],
+ $uname,$udom,$csec);
+ }
# ---------------------------------------------------------------- Done storing
$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
}
-# --------------------------------------------- Devalidate cache for this child
- &Apache::lonnet::devalidatecourseresdata(
- $env{'course.'.$env{'request.course.id'}.'.num'},
- $env{'course.'.$env{'request.course.id'}.'.domain'});
+# ------------------------------------------------------------------- Sort this
+ @ids=sort {
+ if ($fcat eq '') {
+ $a<=>$b;
+ } else {
+ my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
+ my $aparm=$outpar[$result];
+ ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
+ my $bparm=$outpar[$result];
+ 1*$aparm<=>1*$bparm;
+ }
+ } @ids;
#----------------------------------------------- if all selected, fill in array
if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
# ------------------------------------------------------------------ Start page
- my $have_assesments=1;
- if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
+ &startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys)));
- $trimheader = 'yes';
- &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
-
- if (!$have_assesments) {
- return '';
- }
-# if ($env{'form.url'}) {
-# $r->print('<input type="hidden" value="'.$env{'form.url'}.
-# '" name="url"><input type="hidden" name="command" value="set">');
-# }
$r->print('<input type="hidden" value="true" name="prevvisit">');
foreach ('tolerance','date_default','date_start','date_end',
@@ -1035,7 +1140,7 @@
my $csuname=$env{'user.name'};
my $csudom=$env{'user.domain'};
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
my $coursespan=$csec?8:5;
$r->print('<p><table border=2>');
$r->print('<tr><td colspan=5></td>');
@@ -1119,7 +1224,7 @@
my %display=();
my %type= ();
my %default=();
- my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+ my $uri=&Apache::lonnet::declutter($uris{$rid});
foreach (split(/\,/,$keyp{$rid})) {
my $tempkeyp = $_;
@@ -1172,7 +1277,7 @@
undef $firstrow;
}
- &print_row($r,$_,\%part,\%name,$rid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$parmlev,$uname,$udom,$csec);
}
@@ -1181,7 +1286,7 @@
} # end foreach ids
# -------------------------------------------------- End entry for one resource
$r->print('</table>');
- } # end of brief/full
+ } # end of full
#--------------------------------------------------- Entry for parm level map
if ($parmlev eq 'map') {
my $defbgone = '"E0E099"';
@@ -1218,7 +1323,7 @@
# $r->print("$mapid:$map: $rid <br /> \n");
if ($map eq $mapid) {
- my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+ my $uri=&Apache::lonnet::declutter($uris{$rid});
# $r->print("Keys: $keyp{$rid} <br />\n");
#--------------------------------------------------------------------
@@ -1280,7 +1385,7 @@
foreach (sort keys %name) {
$r->print('<tr>');
- &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$parmlev,$uname,$udom,$csec);
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
@@ -1306,7 +1411,7 @@
foreach (@ids) {
my $rid = $_;
- my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
+ my $uri=&Apache::lonnet::declutter($uris{$rid});
#--------------------------------------------------------------------
# @catmarker contains list of all possible parameters including part #s
@@ -1358,7 +1463,7 @@
foreach (sort keys %name) {
$r->print('<tr>');
- &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
}
@@ -1700,7 +1805,8 @@
ENDenv
}
##################################################
-
+# Overview mode
+##################################################
my $tableopen;
sub tablestart {
@@ -1722,26 +1828,38 @@
}
}
-sub overview {
- my $r=shift;
- my $bodytag=&Apache::loncommon::bodytag(
- 'Set/Modify Course Assessment Parameters');
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
- my $html=&Apache::lonxml::xmlbegin();
- $r->print(<<ENDOVER);
-$html
-<head>
-<title>LON-CAPA Course Environment</title>
-</head>
-$bodytag
-$breadcrumbs
-<form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
-<input type="hidden" name="overview" value="1" />
-ENDOVER
+sub readdata {
+ my ($crs,$dom)=@_;
+# Read coursedata
+ my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
+# Read userdata
+
+ my $classlist=&Apache::loncoursedata::get_classlist();
+ foreach (keys %$classlist) {
+ # the following undefs are for 'domain', and 'username' respectively.
+ if ($_=~/^(\w+)\:(\w+)$/) {
+ my ($tuname,$tudom)=($1,$2);
+ my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
+ foreach my $userkey (keys %{$useropt}) {
+ if ($userkey=~/^$env{'request.course.id'}/) {
+ my $newkey=$userkey;
+ $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
+ $$resourcedata{$newkey}=$$useropt{$userkey};
+ }
+ }
+ }
+ }
+ return $resourcedata;
+}
+
+
# Setting
- my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
+
+sub storedata {
+ my ($r,$crs,$dom)=@_;
+# Set userlevel immediately
+# Do an intermediate store of course level
+ my $olddata=&readdata($crs,$dom);
my %newdata=();
undef %newdata;
my @deldata=();
@@ -1750,18 +1868,58 @@
if ($_=~/^form\.([a-z]+)\_(.+)$/) {
my $cmd=$1;
my $thiskey=$2;
+ my ($tuname,$tudom)=&extractuser($thiskey);
+ my $tkey=$thiskey;
+ if ($tuname) {
+ $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
+ }
if ($cmd eq 'set') {
my $data=$env{$_};
- if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
+ if ($$olddata{$thiskey} ne $data) {
+ if ($tuname) {
+ if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') {
+ $r->print('<br />'.&mt('Stored modified parameter for').' '.
+ &Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print('<h2><font color="red">'.
+ &mt('Error storing parameters').'</font></h2>');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ } else {
+ $newdata{$thiskey}=$data;
+ }
+ }
} elsif ($cmd eq 'del') {
- push (@deldata,$thiskey);
+ if ($tuname) {
+ if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
+ $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print('<h2><font color="red">'.
+ &mt('Error deleting parameters').'</font></h2>');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ } else {
+ push (@deldata,$thiskey);
+ }
} elsif ($cmd eq 'datepointer') {
my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
- if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
+ if (defined($data) and $$olddata{$thiskey} ne $data) {
+ if ($tuname) {
+ if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') {
+ $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print('<h2><font color="red">'.
+ &mt('Error storing parameters').'</font></h2>');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ } else {
+ $newdata{$thiskey}=$data;
+ }
+ }
}
}
}
-# Store
+# Store all course level
my $delentries=$#deldata+1;
my @newdatakeys=keys %newdata;
my $putentries=$#newdatakeys+1;
@@ -1772,6 +1930,7 @@
$r->print('<h2><font color="red">'.
&mt('Error deleting parameters').'</font></h2>');
}
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
if ($putentries) {
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
@@ -1780,25 +1939,41 @@
$r->print('<h2><font color="red">'.
&mt('Error storing parameters').'</font></h2>');
}
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
-# Read and display
- my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
+}
+
+sub extractuser {
+ my $key=shift;
+ return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
+}
+
+sub listdata {
+ my ($r,$resourcedata,$listdata)=@_;
+# Start list output
+
my $oldsection='';
my $oldrealm='';
my $oldpart='';
my $pointer=0;
$tableopen=0;
my $foundkeys=0;
- foreach my $thiskey (sort keys %resourcedata) {
- if ($resourcedata{$thiskey.'.type'}) {
- my ($course,$middle,$part,$name)=
- ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ foreach my $thiskey (sort keys %{$listdata}) {
+ if ($$resourcedata{$thiskey.'.type'}) {
+ my ($middle,$part,$name)=
+ ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
my $section=&mt('All Students');
- if ($middle=~/^\[(.*)\]\./) {
- $section=&mt('Group/Section').': '.$1;
- $middle=~s/^\[(.*)\]\.//;
+ if ($middle=~/^\[(.*)\]/) {
+ my $issection=$1;
+ if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
+ $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
+ } else {
+ $section=&mt('Group/Section').': '.$issection;
+ }
+ $middle=~s/^\[(.*)\]//;
}
- $middle=~s/\.$//;
+ $middle=~s/\.+$//;
+ $middle=~s/^\.+//;
my $realm='<font color="red">'.&mt('All Resources').'</font>';
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
$realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
@@ -1828,26 +2003,78 @@
':</b></td><td><input type="checkbox" name="del_'.
$thiskey.'" /></td><td>');
$foundkeys++;
- if ($resourcedata{$thiskey.'.type'}=~/^date/) {
+ if ($$resourcedata{$thiskey.'.type'}=~/^date/) {
my $jskey='key_'.$pointer;
$pointer++;
$r->print(
&Apache::lonhtmlcommon::date_setter('overviewform',
$jskey,
- $resourcedata{$thiskey}).
+ $$resourcedata{$thiskey}).
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
);
} else {
$r->print(
'<input type="text" name="set_'.$thiskey.'" value="'.
- $resourcedata{$thiskey}.'">');
+ $$resourcedata{$thiskey}.'">');
}
$r->print('</td></tr>');
}
}
-
+ return $foundkeys;
+}
+
+sub newoverview {
+ my $r=shift;
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Set Course Assessment Parameters');
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print(<<ENDOVER);
+$html
+<head>
+<title>LON-CAPA Parameters</title>
+</head>
+$bodytag
+$breadcrumbs
+<form method="post" action="/adm/parmset?action=newoverview" name="overviewform">
+ENDOVER
+ $r->print(&tableend().
+ '<p><input type="submit" value="'.&mt('Submit').'" /></p></form></body></html>');
+}
+
+sub overview {
+ my $r=shift;
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Modify Course Assessment Parameters');
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print(<<ENDOVER);
+$html
+<head>
+<title>LON-CAPA Parameters</title>
+</head>
+$bodytag
+$breadcrumbs
+<form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
+ENDOVER
+# Store modified
+
+ &storedata($r,$crs,$dom);
+
+# Read modified data
+
+ my $resourcedata=&readdata($crs,$dom);
+
+# List data
+
+ my $foundkeys=&listdata($r,$resourcedata,$resourcedata);
+
$r->print(&tableend().'<p>'.
- ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
+ ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>');
}
##################################################
@@ -1975,8 +2202,7 @@
my @menu =
(
{ text => 'Set Course Environment Parameters',
- help => 'Course_Setting_Parameters',
- action => 'crsenv',
+ action => 'crsenv',
permission => $parm_permission,
},
{ text => 'Set/Modify Course Assessment Parameters - Helper Mode',
@@ -1986,10 +2212,15 @@
{ text => 'Modify Course Assessment Parameters - Overview Mode',
action => 'setoverview',
permission => $parm_permission,
+ },
+ { text => 'Set Course Assessment Parameters - Overview Mode',
+ action => 'newoverview',
+ permission => $parm_permission,
},
{ text => 'Set/Modify Course Assessment Parameters - Table Mode',
action => 'settable',
permission => $parm_permission,
+ help => 'Cascading_Parameters',
},
# { text => 'Set Parameter Default Preferences',
# help => 'Course_View_Class_List',
@@ -2044,27 +2275,19 @@
return OK;
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','state']);
-
-# ----------------------------------------------------------- Clear out garbage
+ ['action','state',
+ 'pres_marker',
+ 'pres_value',
+ 'pres_type',
+ 'udom','uname']);
- %courseopt=();
- %useropt=();
- %parmhash=();
-
- @ids=();
- %symbp=();
- %mapp=();
- %typep=();
- %keyp=();
-
- %maptitles=();
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
text=>"Parameter Manager",
- faq=>9,
+ faq=>10,
bug=>'Instructor Interface'});
+
# ----------------------------------------------------- Needs to be in a course
my $parm_permission =
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
@@ -2076,6 +2299,11 @@
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
+
+ # id numbers can change on re-ordering of folders
+
+ &resetsymbcache();
+
#
# Main switch on form.action and form.state, as appropriate
#
@@ -2100,9 +2328,14 @@
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
&overview($r);
+ } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
+ text=>"Overview Mode"});
+ &newoverview($r);
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
- text=>"Table Mode"});
+ text=>"Table Mode",
+ help => 'Course_Setting_Parameters'});
&assessparms($r);
}
--www1117906522--