[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface lonwhatsnew.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 04 Jun 2005 03:36:38 -0000


albertel		Fri Jun  3 23:36:38 2005 EDT

  Modified files:              
    /loncom/interface	lonwhatsnew.pm 
    /loncom/homework	grades.pm 
  Log:
  - chanign it so that no longer storing and restoring to a putted DB
  
  
Index: loncom/interface/lonwhatsnew.pm
diff -u loncom/interface/lonwhatsnew.pm:1.16 loncom/interface/lonwhatsnew.pm:1.17
--- loncom/interface/lonwhatsnew.pm:1.16	Fri Jun  3 15:33:37 2005
+++ loncom/interface/lonwhatsnew.pm	Fri Jun  3 23:36:36 2005
@@ -1,5 +1,5 @@
 #
-# $Id: lonwhatsnew.pm,v 1.16 2005/06/03 19:33:37 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.17 2005/06/04 03:36:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -623,8 +623,7 @@
                 $stats{$part}{degdiff} = $degdiff;
                 $stats{$part}{attempts} = $av_attempts;
                 $stats{$part}{users} = $users;
-                my %resethash = &Apache::lonnet::restore($symb,'nohist_resourcetracker',$cdom,$crs);
-                $lastreset{$part} = &get_counter_resets(\%resethash,$part);
+		$lastreset{$part} = $resourcetracker{$symb."\0".$part."\0resettime"};
                 $warning = 1;
             }
         }
@@ -665,22 +664,6 @@
     }
 }
 
-sub get_counter_resets {
-    my ($resethash,$part) = @_;
-    my $lastreset = 'None';
-    if ($$resethash{'version'}) {
-        for (my $version=1;$version<=$$resethash{'version'};$version++) {
-            if (exists($$resethash{$version.':'.$part."\0".'prev_attempts'})) {
-                $lastreset = $$resethash{$version.':timestamp'};
-            }
-        }
-    }
-    unless ($lastreset eq 'None') {
-        $lastreset = localtime($lastreset);
-    }
-    return $lastreset;
-}
-
 sub get_curr_thresholds {
     my ($threshold,$cdom,$crs) = @_;
     my %coursesettings = &Apache::lonnet::dump('environment',
@@ -707,22 +690,20 @@
                      );
     my @resets = ();
     my %titles = ();
-    foreach my $key (keys %env) {
+    foreach my $key (keys(%env)) {
         next if ($key !~ /^form\.reset_(.+)$/);
         my $title = &Apache::lonnet::unescape($env{'form.title_'.$1});
         my $reset_item = &Apache::lonnet::unescape($1);
         my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
-        my %resethash = ();
         my %aggregates = ();
-        my ($symb,$part) = split/\0/,$reset_item;
+        my ($symb,$part) = split(/\0/,$reset_item);
         foreach my $type (@agg_types) {
             $aggregates{$reset_item."\0".$type} = 0;
-            $resethash{$part."\0".'prev_'.$type} = $curr_aggregates{$reset_item."\0".$type};
         }  
+	$aggregates{$reset_item."\0".'resettime'} = time;
         my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
                           $dom,$crs);
         if ($putresult eq 'ok') {
-            my $storeresult = &Apache::lonnet::cstore(\%resethash,$symb,'nohist_resourcetracker',$dom,$crs);
             $result .= $title.' -part '.$part.': ';
             my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
             foreach my $type (@agg_types) {
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.270 loncom/homework/grades.pm:1.271
--- loncom/homework/grades.pm:1.270	Fri Jun  3 22:56:44 2005
+++ loncom/homework/grades.pm	Fri Jun  3 23:36:36 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.270 2005/06/04 02:56:44 albertel Exp $
+# $Id: grades.pm,v 1.271 2005/06/04 03:36:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2273,18 +2273,14 @@
     my %last_resets;
     my $cdom = $env{'course.'.$courseid.'.domain'};
     my $cname = $env{'course.'.$courseid.'.num'};
-    my %resethash = &Apache::lonnet::restore($symb,'nohist_resourcetracker',
-					     $cdom,$cname);
-    if ($resethash{'version'}) {
-        foreach my $part (@{$partids}) {
-            $last_resets{$part} = '';
-            for (my $version=$resethash{'version'};$version>=1;$version--) {
-                if (exists($resethash{$version.':'.$part."\0".'prev_attempts'})) {
-                    $last_resets{$part} = $resethash{$version.':timestamp'};
-                    last;
-                }
-            }
-        }
+    my @keys;
+    foreach my $part (@{$partids}) {
+	push(@keys,"$symb\0$part\0resettime");
+    }
+    my %results=&Apache::lonnet::get('nohist_resourcetracker',\@keys,
+				     $cdom,$cname);
+    foreach my $part (@{$partids}) {
+	$last_resets{$part}=$results{"$symb\0$part\0resettime"};
     }
     return %last_resets;
 }