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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 05 Mar 2003 14:39:08 -0000


matthew		Wed Mar  5 09:39:08 2003 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  &get_current_state() now uses a cache file per student per class instead
  of one for the entire course.  Removed old lonnet::logthis() calls as well.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.55 loncom/interface/loncoursedata.pm:1.56
--- loncom/interface/loncoursedata.pm:1.55	Mon Mar  3 16:52:24 2003
+++ loncom/interface/loncoursedata.pm	Wed Mar  5 09:39:08 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.55 2003/03/03 21:52:24 albertel Exp $
+# $Id: loncoursedata.pm,v 1.56 2003/03/05 14:39:08 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1580,9 +1580,14 @@
     #
     $courseid = $ENV{'request.course.id'} if (! defined($courseid));
     #
+#    my $cachefilename = $Apache::lonnet::tmpdir.$ENV{'user.name'}.'_'.
+#                                                $ENV{'user.domain'}.'_'.
+#                                                $courseid.'_student_data.db';
     my $cachefilename = $Apache::lonnet::tmpdir.$ENV{'user.name'}.'_'.
                                                 $ENV{'user.domain'}.'_'.
-                                                $courseid.'_student_data.db';
+                                                $courseid.'_'.
+                                                $sname.'_'.$sdom.
+                                                    '_student_data.db';
     my %cache;
     #
     my %student_data; # return values go here
@@ -1594,18 +1599,16 @@
     if (tie(%cache,'GDBM_File',$cachefilename,&GDBM_READER(),0640)) {
         if (exists($cache{$key.'time'})) {
             $updatetime = $cache{$key.'time'};
-#            &Apache::lonnet::logthis('got updatetime of '.$updatetime);
         }
         untie(%cache);
     }
-    # timestamp/devalidation 
+    # timestamp/devalidation check should go here.
     my $modifiedtime = 1;
     # Take whatever steps are neccessary at this point to give $modifiedtime a
     # new value
     #
     if (($updatetime < $modifiedtime) || 
         (defined($forcedownload) && $forcedownload)) {
-#        &Apache::lonnet::logthis("loading data");
         # Get all the students current data
         my $time_of_retrieval = time;
         my @tmp = &Apache::lonnet::currentdump($courseid,$sdom,$sname);
@@ -1627,7 +1630,6 @@
         #         keys instead of unescaping every key.
         #
         if (tie(%cache,'GDBM_File',$cachefilename,&GDBM_WRCREAT(),0640)) {
-#            &Apache::lonnet::logthis("writing data");
             while (my ($current_symb,$param_hash) = each(%student_data)) {
                 my @Parameters = %{$param_hash};
                 my $value = join(':',map { &Apache::lonnet::escape($_); } 
@@ -1639,7 +1641,6 @@
             untie(%cache);
         }
     } else {
-        &Apache::lonnet::logthis('retrieving cached data ');
         if (tie(%cache,'GDBM_File',$cachefilename,&GDBM_READER(),0640)) {
             if (defined($symb)) {
                 my  $searchkey = $key.&Apache::lonnet::escape($symb);
@@ -1652,7 +1653,6 @@
                     if ($testkey =~ /$searchkey/) { # \Q \E?  May be necc.
                         my $tmpsymb = $1;
                         next if ($tmpsymb =~ 'time');
-#                        &Apache::lonnet::logthis('found '.$tmpsymb.':');
                         $student_data{&Apache::lonnet::unescape($tmpsymb)} = 
                             &make_into_hash($params);
                     }
@@ -1662,10 +1662,8 @@
         }
     }
     if (! defined($symb)) {
-#        &Apache::lonnet::logthis("returning all data");
         return %student_data;
     } elsif (exists($student_data{$symb})) {
-#        &Apache::lonnet::logthis("returning data for symb=".$symb);
         return %{$student_data{$symb}};
     } else {
         return ();