[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 02 Jun 2005 13:34:15 -0000
www Thu Jun 2 09:34:15 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
parmval and storeparm independent of pre-setting globals
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.198 loncom/interface/lonparmset.pm:1.199
--- loncom/interface/lonparmset.pm:1.198 Thu Jun 2 09:15:05 2005
+++ loncom/interface/lonparmset.pm Thu Jun 2 09:34:14 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.198 2005/06/02 13:15:05 www Exp $
+# $Id: lonparmset.pm,v 1.199 2005/06/02 13:34:14 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,12 +66,12 @@
# --- Caches local to lonparmset
-my $courseoptid='';
-my %courseopt=();
-my $useroptid='';
-my %useropt=();
-my $parmhashid='';
-my %parmhash=();
+my $courseoptid;
+my %courseopt;
+my $useroptid;
+my %useropt;
+my $parmhashid;
+my %parmhash;
# --- end local caches
@@ -121,6 +121,8 @@
my ($what,$id,$def,$uname,$udom,$csec)=@_;
# load caches
&cacheparmhash();
+ &cacheuseropt($uname,$udom);
+ &cachecourseopt();
my $result='';
my @outpar=();
@@ -218,11 +220,29 @@
}
}
+sub resetuseropt {
+ $useroptid='';
+}
+
sub cacheuseropt {
my ($uname,$udom)=@_;
+ unless ($uname) { return; }
+ if ($useroptid eq $uname.'@'.$udom) { return; }
+ %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
+ $useroptid=$uname.'@'.$udom;
+}
+
+sub resetcourseopt {
+ $courseoptid='';
}
sub cachecourseopt {
+ if ($courseoptid eq $env{'request.course.id'}) { return; };
+ %courseopt = &Apache::lonnet::dump
+ ('resourcedata',
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ $courseoptid=$env{'request.course.id'};
}
##################################################
@@ -305,6 +325,7 @@
} else {
&Apache::lonnet::expirespread('','','assesscalc');
}
+ &resetcourseopt();
# Store parameter
if ($delete) {
$reply=&Apache::lonnet::del
@@ -331,6 +352,7 @@
} else {
&Apache::lonnet::expirespread($uname,$udom,'assesscalc');
}
+ &resetuseropt();
# Store parameter
if ($delete) {
$reply=&Apache::lonnet::del
@@ -859,8 +881,6 @@
my %allparts;
my %defp;
- %courseopt=();
- %useropt=();
@ids=();
%symbp=();
@@ -982,15 +1002,6 @@
$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
@@ -2207,9 +2218,6 @@
# ----------------------------------------------------------- Clear out garbage
- %courseopt=();
- %useropt=();
- %parmhash=();
@ids=();
%symbp=();