--- loncom/interface/lonparmset.pm 2005/03/17 20:01:11 1.185
+++ loncom/interface/lonparmset.pm 2005/06/02 16:35:32 1.200
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.185 2005/03/17 20:01:11 albertel Exp $
+# $Id: lonparmset.pm,v 1.200 2005/06/02 16:35:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,25 +62,26 @@ use GDBM_File;
use Apache::lonhomework;
use Apache::lonxml;
use Apache::lonlocal;
+use Apache::lonnavmaps;
-my %courseopt;
-my %useropt;
+# --- Caches local to lonparmset
+
+my $parmhashid;
my %parmhash;
+# --- end local caches
+
+#
+# FIXME: get rid of items below
+#
my @ids;
my %symbp;
my %mapp;
my %typep;
my %keyp;
-
+my %uris;
my %maptitles;
-my $uname;
-my $udom;
-my $uhome;
-my $csec;
-my $coursename;
-
##################################################
##################################################
@@ -113,7 +114,17 @@ Returns: A list, the first item is the
##################################################
##################################################
sub parmval {
- my ($what,$id,$def)=@_;
+ my ($what,$id,$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
@@ -121,25 +132,25 @@ sub parmval {
my $symbparm=$symbp{$id}.'.'.$what;
my $mapparm=$mapp{$id}.'___(all).'.$what;
- my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
- my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
- my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
-
- my $courselevel=$ENV{'request.course.id'}.'.'.$what;
- my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
- my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
+ my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
+ my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+ my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
+
+ my $courselevel=$env{'request.course.id'}.'.'.$what;
+ my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
+ my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
# --------------------------------------------------------- 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;
}
@@ -152,24 +163,25 @@ sub parmval {
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;
}
}
@@ -177,24 +189,161 @@ sub parmval {
# ---------------------------------------------------------- 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'};
+ }
+}
+
+##################################################
+##################################################
+#
+# Store a parameter by ID
+#
+# Takes
+# - resource id
+# - name of parameter
+# - level
+# - new value
+# - new type
+# - username
+# - userdomain
+
+sub storeparm {
+ my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if ($sresid=~/\./) {
+ my $resource=$navmap->getById($sresid);
+ &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
+ } else {
+ my $resource=$navmap->getByMapPc($sresid);
+ &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$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)=@_;
+# ---------------------------------------------------------- Construct prefixes
+ $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;
+
+ my $courselevel=$env{'request.course.id'}.'.'.$spnam;
+ my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
+ my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
+
+ my $storeunder='';
+ if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
+ if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
+ if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
+ if ($snum==6) { $storeunder=$seclevel; }
+ if ($snum==5) { $storeunder=$seclevelm; }
+ if ($snum==4) { $storeunder=$seclevelr; }
+
+ my $delete;
+ if ($nval eq '') { $delete=1;}
+ my %storecontent = ($storeunder => $nval,
+ $storeunder.'.type' => $ntype);
+ my $reply='';
+ 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
+ &Apache::lonnet::expirespread('','','studentcalc');
+ if (($snum==7) || ($snum==4)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$symb);
+ } elsif (($snum==8) || ($snum==5)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$map);
+ } else {
+ &Apache::lonnet::expirespread('','','assesscalc');
+ }
+# Store parameter
+ if ($delete) {
+ $reply=&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
+ } else {
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$cdom,$cnum);
+ }
+ &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
+ } else {
+# ------------------------------------------------------------------ Store User
+#
+# Expire sheets
+ &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
+ if ($snum==1) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$symb);
+ } elsif ($snum==2) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$map);
+ } else {
+ &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
+ }
+# Store parameter
+ if ($delete) {
+ $reply=&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$udom,$uname);
+ } else {
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$udom,$uname);
+ }
+ &Apache::lonnet::devalidateuserresdata($uname,$udom);
+ }
+
+ if ($reply=~/^error\:(.*)/) {
+ return "Write Error: $1 ";
+ }
+ return '';
+}
+
##################################################
##################################################
@@ -275,9 +424,9 @@ sub plink {
my $winvalue=$value;
unless ($winvalue) {
if ($type=~/^date/) {
- $winvalue=$ENV{'form.recent_'.$type};
+ $winvalue=$env{'form.recent_'.$type};
} else {
- $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
+ $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
}
return
@@ -292,6 +441,7 @@ sub startpage {
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
'onUnload="pclose()"');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table');
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
&Apache::loncommon::selectstudent_link('parmform','uname','udom');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
@@ -361,6 +511,7 @@ $html
$selscript
$bodytag
+$breadcrumbs
$overallhelp
ENDHEAD
@@ -382,9 +533,22 @@ $assessparmhelp
ENDHEAD2
-}
- $r->print(<
+ }
+ my %sectionhash=();
+ my $sections='';
+ if (&Apache::loncommon::get_sections(
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'},
+ \%sectionhash)) {
+ $sections=$lt{'sg'}.': ';
+ foreach ('',sort keys %sectionhash) {
+ $sections.=''.$_.' ';
+ }
+ $sections.=' ';
+ }
+ $r->print(<
$lt{'captm'}
ENDHEAD3
@@ -393,13 +557,12 @@ ENDHEAD3
} else {
$r->print(<
-$lt{'sg'}:
-
-
+$sections
+
$lt{'fu'}
-
+
$lt{'oi'}
-
+
$lt{'ad'}
$chooseopt
@@ -412,16 +575,16 @@ ENDHEAD
sub print_row {
my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
- $defbgtwo,$parmlev)=@_;
+ $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},
- $rid,$$default{$which});
+ $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',
- $rid,$$defaulttype{$which});
+ $rid,$$defaulttype{$which},$uname,$udom,$csec);
# cascade down manually
my $cascadetype=$$defaulttype{$which};
for (my $i=11;$i>0;$i--) {
@@ -568,7 +731,6 @@ Input: See list below:
=cut
sub extractResourceInformation {
- my $bighash = shift;
my $ids = shift;
my $typep = shift;
my $keyp = shift;
@@ -581,63 +743,62 @@ sub extractResourceInformation {
my $mapp = shift;
my $symbp = shift;
my $maptitles=shift;
+ my $uris=shift;
+
- foreach (keys %$bighash) {
- if ($_=~/^src\_(\d+)\.(\d+)$/) {
- # there are no resources in the 0 level
- if ($1 eq '0') { next; }
- my $mapid=$1;
- my $resid=$2;
- my $id=$mapid.'.'.$resid;
- my $srcf=$$bighash{$_};
- if (1) {
- $srcf=~/\.(\w+)$/;
- $$ids[$#$ids+1]=$id;
- $$typep{$id}=$1;
- $$keyp{$id}='';
- 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;
- }
- }
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
+ foreach my $resource (@allres) {
+ 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
}
- $$mapp{$id}=
- &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
- $$mapp{$mapid}=$$mapp{$id};
- $$allmaps{$mapid}=$$mapp{$id};
- if ($mapid eq '1') {
- $$maptitles{$mapid}='Main Course Documents';
+ 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 {
- $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+ $$keyp{$id}=$key;
}
- $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
- $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
- $$symbp{$mapid}=$$mapp{$id}.'___(all)';
}
}
+ $$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)';
}
}
@@ -679,8 +840,14 @@ sub assessparms {
my %allmaps=();
my %alllevs=();
+ my $uname;
+ my $udom;
+ my $uhome;
+ my $csec;
+
+ my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
+
$alllevs{'Resource Level'}='full';
-# $alllevs{'Resource Level [BRIEF]'}='brief';
$alllevs{'Map Level'}='map';
$alllevs{'Course Level'}='general';
@@ -688,9 +855,6 @@ sub assessparms {
my %allparts;
my %defp;
- %courseopt=();
- %useropt=();
- my %bighash=();
@ids=();
%symbp=();
@@ -698,57 +862,54 @@ sub assessparms {
my $message='';
- $csec=$ENV{'form.csec'};
- if ($udom=$ENV{'form.udom'}) {
- } elsif ($udom=$ENV{'request.role.domain'}) {
- } elsif ($udom=$ENV{'user.domain'}) {
+ $csec=$env{'form.csec'};
+
+ if ($udom=$env{'form.udom'}) {
+ } elsif ($udom=$env{'request.role.domain'}) {
+ } elsif ($udom=$env{'user.domain'}) {
} else {
$udom=$r->dir_config('lonDefDomain');
}
my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
- my $pschp=$ENV{'form.pschp'};
+ 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 $showoptions=$env{'form.showoptions'};
my $pssymb='';
my $parmlev='';
my $trimheader='';
- my $prevvisit=$ENV{'form.prevvisit'};
-
-# unless ($parmlev==$ENV{'form.parmlev'}) {
-# $parmlev = 'full';
-# }
+ my $prevvisit=$env{'form.prevvisit'};
- unless ($ENV{'form.parmlev'}) {
+ unless ($env{'form.parmlev'}) {
$parmlev = 'map';
} else {
- $parmlev = $ENV{'form.parmlev'};
+ $parmlev = $env{'form.parmlev'};
}
# ----------------------------------------------- Was this started from grades?
- if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
- && (!$ENV{'form.dis'})) {
- my $url=$ENV{'form.url'};
+ if (($env{'form.command'} eq 'set') && ($env{'form.url'})
+ && (!$env{'form.dis'})) {
+ my $url=$env{'form.url'};
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
$pssymb=&Apache::lonnet::symbread($url);
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
$trimheader='yes';
- } elsif ($ENV{'form.symb'}) {
- $pssymb=$ENV{'form.symb'};
+ } elsif ($env{'form.symb'}) {
+ $pssymb=$env{'form.symb'};
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
$trimheader='yes';
} else {
- $ENV{'form.url'}='';
+ $env{'form.url'}='';
}
- my $id=$ENV{'form.id'};
+ my $id=$env{'form.id'};
if (($id) && ($udom)) {
$uname=(&Apache::lonnet::idget($udom,$id))[1];
if ($uname) {
@@ -759,7 +920,7 @@ sub assessparms {
&mt('at domain')." '$udom'";
}
} else {
- $uname=$ENV{'form.uname'};
+ $uname=$env{'form.uname'};
}
unless ($udom) { $uname=''; }
$uhome='';
@@ -772,13 +933,13 @@ sub assessparms {
$uname='';
} else {
$csec=&Apache::lonnet::getsection($udom,$uname,
- $ENV{'request.course.id'});
+ $env{'request.course.id'});
if ($csec eq '-1') {
$message="".
&mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
&mt("not in this course")." ";
$uname='';
- $csec=$ENV{'form.csec'};
+ $csec=$env{'form.csec'};
} else {
my %name=&Apache::lonnet::userenvironment($udom,$uname,
('firstname','middlename','lastname','generation','id'));
@@ -792,135 +953,33 @@ sub assessparms {
unless ($csec) { $csec=''; }
- my $fcat=$ENV{'form.fcat'};
+ my $fcat=$env{'form.fcat'};
unless ($fcat) { $fcat=''; }
-# ------------------------------------------------------------------- Tie hashs
- if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
- &GDBM_READER(),0640))) {
- $r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
- return ;
- }
- if (!(tie(%parmhash,'GDBM_File',
- $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
- $r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
- return ;
- }
-
# --------------------------------------------------------- Get all assessments
- extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles);
+ &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'}) {
- my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
- $spnam=~s/\_([^\_]+)$/\.$1/;
-# ---------------------------------------------------------- Construct prefixes
-
- my $symbparm=$symbp{$sresid}.'.'.$spnam;
- my $mapparm=$mapp{$sresid}.'___(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;
-
- my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
- my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
- my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
-
- my $storeunder='';
- if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
- if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
- if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
- if ($snum==6) { $storeunder=$seclevel; }
- if ($snum==5) { $storeunder=$seclevelm; }
- if ($snum==4) { $storeunder=$seclevelr; }
-
- my $delete;
- if ($ENV{'form.pres_value'} eq '') { $delete=1;}
- my %storecontent = ($storeunder => $ENV{'form.pres_value'},
- $storeunder.'.type' => $ENV{'form.pres_type'});
- my $reply='';
- if ($snum>3) {
-# ---------------------------------------------------------------- Store Course
-#
-# Expire sheets
- &Apache::lonnet::expirespread('','','studentcalc');
- if (($snum==7) || ($snum==4)) {
- &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
- } elsif (($snum==8) || ($snum==5)) {
- &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
- } else {
- &Apache::lonnet::expirespread('','','assesscalc');
- }
-# 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'});
- } else {
- $reply=&Apache::lonnet::cput
- ('resourcedata',\%storecontent,
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- }
- } else {
-# ------------------------------------------------------------------ Store User
-#
-# Expire sheets
- &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
- if ($snum==1) {
- &Apache::lonnet::expirespread
- ($uname,$udom,'assesscalc',$symbp{$sresid});
- } elsif ($snum==2) {
- &Apache::lonnet::expirespread
- ($uname,$udom,'assesscalc',$mapp{$sresid});
- } else {
- &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
- }
-# Store parameter
- if ($delete) {
- $reply=&Apache::lonnet::del
- ('resourcedata',[keys(%storecontent)],$udom,$uname);
- } else {
- $reply=&Apache::lonnet::cput
- ('resourcedata',\%storecontent,$udom,$uname);
- }
- }
-
- if ($reply=~/^error\:(.*)/) {
- $message.="Write Error: $1 ";
- }
+ if ($env{'form.pres_marker'}) {
+ $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
+ $env{'form.pres_value'},
+ $env{'form.pres_type'},
+ $uname,$udom,$csec);
# ---------------------------------------------------------------- Done storing
$message.=''.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').' ';
}
-# --------------------------------------------- Devalidate cache for this child
- &Apache::lonnet::devalidatecourseresdata(
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
- &Apache::lonnet::clear_EXT_cache_status();
-# -------------------------------------------------------------- Get coursedata
- %courseopt = &Apache::lonnet::dump
- ('resourcedata',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
-# --------------------------------------------------- Get userdata (if present)
- if ($uname) {
- %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
- }
-
# ------------------------------------------------------------------- Sort this
@ids=sort {
if ($fcat eq '') {
$a<=>$b;
} else {
- my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
+ my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
my $aparm=$outpar[$result];
- ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
+ ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
my $bparm=$outpar[$result];
1*$aparm<=>1*$bparm;
}
@@ -933,15 +992,11 @@ sub assessparms {
my $have_assesments=1;
if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
+ $trimheader = 'yes';
&startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
- if (!$have_assesments) {
- untie(%bighash);
- untie(%parmhash);
- return '';
- }
-# if ($ENV{'form.url'}) {
-# $r->print(' ');
# }
$r->print(' ');
@@ -949,7 +1004,7 @@ sub assessparms {
foreach ('tolerance','date_default','date_start','date_end',
'date_interval','int','float','string') {
$r->print(' ');
+ $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
}
$r->print(''.$message.' ');
@@ -1115,8 +1170,8 @@ sub assessparms {
if (($prevvisit) || ($pschp) || ($pssymb)) {
# ----------------------------------------------------------------- Start Table
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
- my $csuname=$ENV{'user.name'};
- my $csudom=$ENV{'user.domain'};
+ my $csuname=$env{'user.name'};
+ my $csudom=$env{'user.domain'};
if ($parmlev eq 'full' || $parmlev eq 'brief') {
my $coursespan=$csec?8:5;
@@ -1158,8 +1213,8 @@ ENDTABLETWO
$r->print(<$lt{'aut'} $lt{'type'}
$lt{'emof'} $lt{'part'} $lt{'pn'}
-$lt{'gen'} $lt{'femof'}
-$lt{'def'} $lt{'foremf'} $lt{'fr'}
+$lt{'gen'} $lt{'foremf'}
+$lt{'def'} $lt{'femof'} $lt{'fr'}
ENDTABLEHEADFOUR
if ($csec) {
@@ -1202,7 +1257,7 @@ ENDTABLEHEADFOUR
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 = $_;
@@ -1257,7 +1312,7 @@ ENDTABLEHEADFOUR
&print_row($r,$_,\%part,\%name,$rid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
- $parmlev);
+ $parmlev,$uname,$udom,$csec);
}
}
}
@@ -1301,7 +1356,7 @@ ENDTABLEHEADFOUR
# $r->print("$mapid:$map: $rid \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} \n");
#--------------------------------------------------------------------
@@ -1365,7 +1420,7 @@ ENDMAPONE
$r->print('');
&print_row($r,$_,\%part,\%name,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
- $parmlev);
+ $parmlev,$uname,$udom,$csec);
# $r->print(" resource.$part{$_}.$name{$_},$symbp{$mapid} \n");
}
$r->print("
");
@@ -1389,7 +1444,7 @@ ENDMAPONE
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
@@ -1442,15 +1497,13 @@ ENDMAPONE
foreach (sort keys %name) {
$r->print('');
&print_row($r,$_,\%part,\%name,$mapid,\%default,
- \%type,\%display,$defbgone,$defbgtwo,$parmlev);
+ \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
# $r->print(" resource.$part{$_}.$name{$_},$symbp{$mapid} \n");
}
$r->print("");
} # end of $parmlev eq general
}
$r->print('