[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 02 Jun 2005 13:15:07 -0000


www		Thu Jun  2 09:15:07 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Make parmval self-sufficient
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.197 loncom/interface/lonparmset.pm:1.198
--- loncom/interface/lonparmset.pm:1.197	Wed Jun  1 17:44:00 2005
+++ loncom/interface/lonparmset.pm	Thu Jun  2 09:15:05 2005
@@ -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::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 @@
 ##################################################
 sub parmval {
     my ($what,$id,$def,$uname,$udom,$csec)=@_;
+# load caches
+    &cacheparmhash();
+
     my $result='';
     my @outpar=();
 # ----------------------------------------------------- Cascading lookup scheme
@@ -190,6 +203,27 @@
     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 @@
     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 @@
     $trimheader = 'yes';
     &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
 
-    if (!$have_assesments) {
-	untie(%parmhash);
-	return '';
-    }
 #    if ($env{'form.url'}) {
 #	$r->print('<input type="hidden" value="'.$env{'form.url'}.
 #		  '" name="url"><input type="hidden" name="command" value="set">');
@@ -1503,7 +1525,6 @@
         } # end of $parmlev eq general
     }
     $r->print('</form></body></html>');
-    untie(%parmhash);
 } # end sub assessparms