--- loncom/interface/lonparmset.pm 2005/06/01 21:44:00 1.197 +++ loncom/interface/lonparmset.pm 2005/06/02 13:15:05 1.198 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.197 2005/06/01 21:44:00 www Exp $ +# $Id: lonparmset.pm,v 1.198 2005/06/02 13:15:05 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -64,10 +64,20 @@ use Apache::lonxml; use Apache::lonlocal; use Apache::lonnavmaps; -my %courseopt; -my %useropt; -my %parmhash; +# --- Caches local to lonparmset +my $courseoptid=''; +my %courseopt=(); +my $useroptid=''; +my %useropt=(); +my $parmhashid=''; +my %parmhash=(); + +# --- end local caches + +# +# FIXME: get rid of items below +# my @ids; my %symbp; my %mapp; @@ -109,6 +119,9 @@ Returns: A list, the first item is the ################################################## sub parmval { my ($what,$id,$def,$uname,$udom,$csec)=@_; +# load caches + &cacheparmhash(); + my $result=''; my @outpar=(); # ----------------------------------------------------- Cascading lookup scheme @@ -190,6 +203,27 @@ sub parmval { 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 cacheuseropt { + my ($uname,$udom)=@_; +} + +sub cachecourseopt { +} ################################################## ################################################## @@ -928,14 +962,6 @@ sub assessparms { my $fcat=$env{'form.fcat'}; unless ($fcat) { $fcat=''; } -# ------------------------------------------------------------------- Tie hashs - - 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(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris); @@ -990,10 +1016,6 @@ sub assessparms { $trimheader = 'yes'; &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); - if (!$have_assesments) { - untie(%parmhash); - return ''; - } # if ($env{'form.url'}) { # $r->print(''); @@ -1503,7 +1525,6 @@ ENDMAPONE } # end of $parmlev eq general } $r->print(''); - untie(%parmhash); } # end sub assessparms