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

stredwic lon-capa-cvs@mail.lon-capa.org
Thu, 15 Aug 2002 16:03:11 -0000


stredwic		Thu Aug 15 12:03:11 2002 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  Modified regular expression, still needs more work.  Added while each
  instead of foreach for the keys in a hash.  That reduced the size
  of the httpd to its normal size instead of ballooning.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.17 loncom/interface/loncoursedata.pm:1.18
--- loncom/interface/loncoursedata.pm:1.17	Wed Aug 14 17:51:51 2002
+++ loncom/interface/loncoursedata.pm	Thu Aug 15 12:03:11 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: loncoursedata.pm,v 1.17 2002/08/14 21:51:51 stredwic Exp $
+# $Id: loncoursedata.pm,v 1.18 2002/08/15 16:03:11 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1013,9 +1013,10 @@
     my $studentCount = scalar(@$students);
     my %cache;
 
+
     my $WhatIWant;
-    $WhatIWant = '(^version:(\w|\/|\.|-)+?$|';
-    $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.';
+    $WhatIWant = '(^version:.+?$|';
+    $WhatIWant .= '^\d+:.+?:(resource\.\d+\.';
     $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';
     $WhatIWant .= '|timestamp)';
     $WhatIWant .= ')';
@@ -1077,9 +1078,10 @@
     my $title = 'LON-CAPA Statistics';
     my $heading = 'Download Course Data';
 
+#    my $WhatIWant = '.';
     my $WhatIWant;
-    $WhatIWant = '(^version:(\w|\/|\.|-)+?$|';
-    $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.';
+    $WhatIWant = '(^version:.+?$|';
+    $WhatIWant .= '^\d+:.+?:(resource\.\d+\.';
     $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';
     $WhatIWant .= '|timestamp)';
     $WhatIWant .= ')';
@@ -1087,10 +1089,6 @@
     &CheckForResidualDownload($courseID, $cacheDB, $students, $c);
 
     my %cache;
-    my %downloadData;
-    unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_NEWDB(),0640)) {
-        return 'Failed to tie temporary download hash.';
-    }
 
     my $studentCount = scalar(@$students);
     if($status eq 'true') {
@@ -1100,7 +1098,6 @@
     my $displayString='';
     foreach (@$students) {
         if($c->aborted()) {
-            untie(%downloadData);
             return 'Aborted';
         }
 
@@ -1118,7 +1115,6 @@
         }
 
         if($c->aborted()) {
-            untie(%downloadData);
             return 'Aborted';
         }
 
@@ -1127,6 +1123,11 @@
             my $courseData = 
                 &DownloadCourseInformation($_, $courseID, $downloadTime,
                                            $WhatIWant);
+            my %downloadData;
+            unless(tie(%downloadData,'GDBM_File',$residualFile,
+                       &GDBM_WRCREAT(),0640)) {
+                return 'Failed to tie temporary download hash.';
+            }
             foreach my $key (keys(%$courseData)) {
                 $downloadData{$key} = $courseData->{$key};
                 if($key =~ /^(con_lost|error|no_such_host)/i) {
@@ -1140,11 +1141,11 @@
                 }
                 $downloadData{$_.':error'} = 'No course data for '.$_;
             }
+            untie(%downloadData);
         }
     }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
 
-    untie(%downloadData);
     return &CheckForResidualDownload($cacheDB, 'true', 'true', 
                                      $courseID, $r, $c);
 }
@@ -1154,7 +1155,7 @@
 
     my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db';
     if(!-e $residualFile) {
-        return 'File does not exist';
+        return 'OK';
     }
 
     my %downloadData;
@@ -1167,11 +1168,11 @@
         return 'Can not tie database for check for residual download: cacheDB';
     }
 
-    my @dataKeys=keys(%downloadData);
     my @students=();
     my %checkStudent;
-    foreach(@dataKeys) {
-        my @temp = split(':', $_);
+    my $key;
+    while(($key, undef) = each %downloadData) {
+        my @temp = split(':', $key);
         my $student = $temp[0].':'.$temp[1];
         if(!defined($checkStudent{$student})) {
             $checkStudent{$student}++;
@@ -1199,11 +1200,6 @@
             &ExtractStudentData(\%downloadData, \%cache, \%cache, $name);
         } else {
             &ProcessStudentData(\%cache, \%downloadData, $name);
-        }
-        foreach (@dataKeys) {
-            if(/^$name/) {
-                delete $downloadData{$_};
-            }
         }
         $count++;
     }