[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 02 Jun 2005 16:35:34 -0000
www Thu Jun 2 12:35:34 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Use lonnet caches of parmvals
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.199 loncom/interface/lonparmset.pm:1.200
--- loncom/interface/lonparmset.pm:1.199 Thu Jun 2 09:34:14 2005
+++ loncom/interface/lonparmset.pm Thu Jun 2 12:35:32 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.199 2005/06/02 13:34:14 www Exp $
+# $Id: lonparmset.pm,v 1.200 2005/06/02 16:35:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,10 +66,6 @@
# --- Caches local to lonparmset
-my $courseoptid;
-my %courseopt;
-my $useroptid;
-my %useropt;
my $parmhashid;
my %parmhash;
@@ -120,9 +116,14 @@
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec)=@_;
# load caches
+
&cacheparmhash();
- &cacheuseropt($uname,$udom);
- &cachecourseopt();
+
+ 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=();
@@ -143,13 +144,13 @@
# --------------------------------------------------------- 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;
}
@@ -162,24 +163,25 @@
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;
}
}
@@ -187,18 +189,18 @@
# ---------------------------------------------------------- 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;
}
}
@@ -220,31 +222,6 @@
}
}
-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'};
-}
-
##################################################
##################################################
#
@@ -316,6 +293,8 @@
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)) {
@@ -325,19 +304,15 @@
} else {
&Apache::lonnet::expirespread('','','assesscalc');
}
- &resetcourseopt();
# 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
#
@@ -352,7 +327,6 @@
} else {
&Apache::lonnet::expirespread($uname,$udom,'assesscalc');
}
- &resetuseropt();
# Store parameter
if ($delete) {
$reply=&Apache::lonnet::del
@@ -997,12 +971,6 @@
# ---------------------------------------------------------------- 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'});
- #&Apache::lonnet::clear_EXT_cache_status();
-
# ------------------------------------------------------------------- Sort this
@ids=sort {