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

stredwic lon-capa-cvs@mail.lon-capa.org
Wed, 28 Aug 2002 22:42:16 -0000


stredwic		Wed Aug 28 18:42:16 2002 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm lonstatistics.pm 
  Log:
  Now I untie the hash before I try to download the data.
  
  Update all students was not working because the untie that was performed
  before the call to DownloadStudentCourseData did nothing because it
  was not on the same level as its associated tie :(  Moved ties onto
  the same level in DownloadStudentCourseData and lonstatistics::PrepareData.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.23 loncom/interface/loncoursedata.pm:1.24
--- loncom/interface/loncoursedata.pm:1.23	Wed Aug 28 18:02:47 2002
+++ loncom/interface/loncoursedata.pm	Wed Aug 28 18:42:15 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: loncoursedata.pm,v 1.23 2002/08/28 22:02:47 stredwic Exp $
+# $Id: loncoursedata.pm,v 1.24 2002/08/28 22:42:15 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1095,8 +1095,6 @@
     my $title = 'LON-CAPA Statistics';
     my $heading = 'Download and Process Course Data';
     my $studentCount = scalar(@$students);
-    my %cache;
-
 
     my $WhatIWant;
     $WhatIWant = '(^version:|';
@@ -1113,6 +1111,8 @@
     my $displayString;
     my $count=0;
     foreach (@$students) {
+        my %cache;
+
         if($c->aborted()) { return 'Aborted'; }
 
         if($status eq 'true') {
@@ -1130,27 +1130,28 @@
 
         if($c->aborted()) { return 'Aborted'; }
 
-        if($downloadTime eq 'Not downloaded') {
-            my $courseData = 
-                &DownloadCourseInformation($_, $courseID, $downloadTime, 
-                                           $WhatIWant);
-            if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
-                foreach my $key (keys(%$courseData)) {
-                    if($key =~ /^(con_lost|error|no_such_host)/i) {
-                        $courseData->{$_.':error'} = 'No course data for '.$_;
-                        last;
-                    }
-                }
-                if($extract eq 'true') {
-                    &ExtractStudentData($courseData, \%cache, \%cache, $_);
-                } else {
-                    &ProcessStudentData(\%cache, $courseData, $_);
-                }
-                untie(%cache);
-            } else {
-                next;
-            }
-        }
+        if($downloadTime ne 'Not downloaded') {
+	    next;
+	}
+	my $courseData = 
+	    &DownloadCourseInformation($_, $courseID, $downloadTime, 
+				       $WhatIWant);
+	if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+	    foreach my $key (keys(%$courseData)) {
+		if($key =~ /^(con_lost|error|no_such_host)/i) {
+		    $courseData->{$_.':error'} = 'No course data for '.$_;
+		    last;
+		}
+	    }
+	    if($extract eq 'true') {
+		&ExtractStudentData($courseData, \%cache, \%cache, $_);
+	    } else {
+		&ProcessStudentData(\%cache, $courseData, $_);
+	    }
+	    untie(%cache);
+	} else {
+	    next;
+	}
     }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
 
@@ -1172,8 +1173,6 @@
 
     &CheckForResidualDownload($courseID, $cacheDB, $students, $c);
 
-    my %cache;
-
     my $studentCount = scalar(@$students);
     if($status eq 'true') {
         &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
@@ -1191,6 +1190,7 @@
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }
 
+        my %cache;
         my $downloadTime='Not downloaded';
         if($checkDate eq 'true'  && 
            tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.47 loncom/interface/lonstatistics.pm:1.48
--- loncom/interface/lonstatistics.pm:1.47	Wed Aug 21 13:18:08 2002
+++ loncom/interface/lonstatistics.pm	Wed Aug 28 18:42:15 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.47 2002/08/21 17:18:08 www Exp $
+# $Id: lonstatistics.pm,v 1.48 2002/08/28 22:42:15 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -359,40 +359,39 @@
     &SpaceColumns($students, $studentInformation, $headings, \%cache);
     $cache{'updateTime:columnWidth'}=24;
 
-    if($cache{'download'} ne 'false') {
-        my @who = ($cache{'download'});
+    my $download = $cache{'download'};
+    my $downloadAll = $cache{'DownloadAll'};
+    my @allStudents=();
+    if($download ne 'false') {
         $cache{'download'} = 'false';
+    } elsif($downloadAll ne 'false') {
+        $cache{'DownloadAll'} = 'false';
+        if($downloadAll eq 'sorted') {
+            @allStudents = @$students;
+        } else {
+            @allStudents = split(':::', $cache{'NamesOfStudents'});
+        }
+    }
+
+    untie(%cache);
+
+    if($download ne 'false') {
+        my @who = ($download);
         if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'false', 
                                                              $cacheDB, 'true', 
                                                              'false', $courseID,
                                                              $r, $c) ne 'OK') {
-            untie(%cache);
             return 'Stop at download individual';
         }
-    } elsif($cache{'DownloadAll'} ne 'false') {
-        $cache{'DownloadAll'} = 'false';
-        my @allStudents;
-        if($cache{'DownloadAll'} eq 'sorted') {
-            @allStudents = @$students;
-        } else {
-            @allStudents = split(':::', $cache{'NamesOfStudents'});
-        }
+    } elsif($downloadAll ne 'false') {
         if(&Apache::loncoursedata::DownloadStudentCourseData(\@allStudents, 
                                                              'false', 
                                                              $cacheDB, 'true', 
                                                              'true', $courseID,
                                                              $r, $c) ne 'OK') {
-            untie(%cache);
             return 'Stop at download all';
         }
     }
-
-    if($c->aborted()) {
-        untie(%cache);
-        return 'aborted'; 
-    }
-
-    untie(%cache);
 
     return ('OK', $students);
 }