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

stredwic lon-capa-cvs@mail.lon-capa.org
Wed, 14 Aug 2002 21:51:51 -0000


This is a MIME encoded message

--stredwic1029361911
Content-Type: text/plain

stredwic		Wed Aug 14 17:51:51 2002 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
    /loncom/interface/statistics	lonproblemanalysis.pm 
                                	lonproblemstatistics.pm 
  Log:
  Fixed the number not updating in the status window for update all students
  button.  Also fixed some tieing to hash problems for lonproblemstatistics
  and lonproblemanalysis.
  
  
--stredwic1029361911
Content-Type: text/plain
Content-Disposition: attachment; filename="stredwic-20020814175151.txt"

Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.16 loncom/interface/loncoursedata.pm:1.17
--- loncom/interface/loncoursedata.pm:1.16	Wed Aug 14 12:18:55 2002
+++ loncom/interface/loncoursedata.pm	Wed Aug 14 17:51:51 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: loncoursedata.pm,v 1.16 2002/08/14 16:18:55 stredwic Exp $
+# $Id: loncoursedata.pm,v 1.17 2002/08/14 21:51:51 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1023,11 +1023,14 @@
     if($status eq 'true') {
         &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
     }
-    my $count=1;
+
+    my $displayString;
+    my $count=0;
     foreach (@$students) {
         if($c->aborted()) { return 'Aborted'; }
 
         if($status eq 'true') {
+            $count++;
             my $displayString = $count.'/'.$studentCount.': '.$_;
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }
@@ -1062,7 +1065,6 @@
                 next;
             }
         }
-        $count++;
     }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
 
@@ -1094,7 +1096,8 @@
     if($status eq 'true') {
         &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
     }
-    my $count=1;
+    my $count=0;
+    my $displayString='';
     foreach (@$students) {
         if($c->aborted()) {
             untie(%downloadData);
@@ -1102,7 +1105,8 @@
         }
 
         if($status eq 'true') {
-            my $displayString = $count.'/'.$studentCount.': '.$_;
+            $count++;
+            $displayString = $count.'/'.$studentCount.': '.$_;
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }
 
@@ -1137,10 +1141,10 @@
                 $downloadData{$_.':error'} = 'No course data for '.$_;
             }
         }
-        $count++;
     }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
 
+    untie(%downloadData);
     return &CheckForResidualDownload($cacheDB, 'true', 'true', 
                                      $courseID, $r, $c);
 }
@@ -1150,14 +1154,17 @@
 
     my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db';
     if(!-e $residualFile) {
-        return;
+        return 'File does not exist';
     }
 
     my %downloadData;
     my %cache;
-    unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640) &&
-           tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
-        return;
+    unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640)) {
+        return 'Can not tie database for check for residual download: tempDB';
+    }
+    unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+        untie(%downloadData);
+        return 'Can not tie database for check for residual download: cacheDB';
     }
 
     my @dataKeys=keys(%downloadData);
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.8 loncom/interface/statistics/lonproblemanalysis.pm:1.9
--- loncom/interface/statistics/lonproblemanalysis.pm:1.8	Wed Aug 14 16:42:49 2002
+++ loncom/interface/statistics/lonproblemanalysis.pm	Wed Aug 14 17:51:51 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonproblemanalysis.pm,v 1.8 2002/08/14 20:42:49 stredwic Exp $
+# $Id: lonproblemanalysis.pm,v 1.9 2002/08/14 21:51:51 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -115,17 +115,21 @@
             splice(@$students, $studentIndex, 1);
         }
     }
-    untie(%cache);
+    unless(untie(%cache)) {
+        $r->print('Can not untie hash.');
+        $r->rflush();
+    }
 
-    if(&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, 
-                                                                 'true', 
-                                                                 $cacheDB, 
-                                                                 'true', 
-                                                                 'true', 
-                                                                 $courseID, 
-                                                                 $r, 
-                                                                 $c) ne 'OK') {
-        $r->print($Str);
+    my $error = 
+        &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
+                                                                  'true',
+                                                                  $cacheDB,
+                                                                  'true', 
+                                                                  'true',
+                                                                  $courseID,
+                                                                  $r, $c);
+    if($error ne 'OK') {
+        $r->print($error.'<br>Error downloading course data<br>');
         return;
     }
 
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.27 loncom/interface/statistics/lonproblemstatistics.pm:1.28
--- loncom/interface/statistics/lonproblemstatistics.pm:1.27	Wed Aug 14 16:42:49 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm	Wed Aug 14 17:51:51 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonproblemstatistics.pm,v 1.27 2002/08/14 20:42:49 stredwic Exp $
+# $Id: lonproblemstatistics.pm,v 1.28 2002/08/14 21:51:51 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,7 +52,7 @@
     $jr = $r;
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database.');
+        $r->print('Unable to tie database1.');
         return ('ERROR', undef);
     }
 
@@ -80,26 +80,32 @@
         }
     }
 
+    my $isNotCached = 0;
     my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
                      $cache{'StatisticsLastStatus'} : 'Nothing';
     my $whichStudents = join(':::',sort(@$students));
     if(!defined($cache{'StatisticsCached'}) || 
        $lastStatus ne $cache{'Status'} ||
        $whichStudents ne $cache{'StatisticsWhichStudents'}) {
-        if(defined($cache{'StatisticsCached'})) {
-            untie(%cache);
-            unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
-                $r->print('Unable to tie database.');
-                return ('ERROR', undef);
-            }
-            my @statkeys = split(':::', $cache{'StatisticsKeys'});
-            delete $cache{'StatisticsKeys'};
-            delete $cache{'StatisticsCached'};
-            foreach(@statkeys) {
-                delete $cache{$_};
-            }
+        $isNotCached = 1;
+    }
+
+    untie(%cache);
+    unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+        $r->print('Unable to tie database.2');
+        return ('ERROR', undef);
+    }
+    if($isNotCached && defined($cache{'StatisticsCached'})) {
+        my @statkeys = split(':::', $cache{'StatisticsKeys'});
+        delete $cache{'StatisticsKeys'};
+        delete $cache{'StatisticsCached'};
+        foreach(@statkeys) {
+            delete $cache{$_};
         }
-        untie(%cache);
+    }
+
+    untie(%cache);
+    if($isNotCached) {
         &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
                                                                   'true',
                                                                   $cacheDB,
@@ -107,20 +113,25 @@
                                                                   'true',
                                                                   $courseID,
                                                                   $r, $c);
-        if($c->aborted()) { return ('ERROR', undef); }
+    }
+    if($c->aborted()) { return ('ERROR', undef); }
 
-        unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-            $r->print('Unable to tie database.');
-            return ('ERROR', undef);
-        }
-        my ($problemData) = &ExtractStudentData(\%cache, $students);
+    unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+        $r->print('Unable to tie database.3');
+        return ('ERROR', undef);
+    }
+    my $problemData;
+    if($isNotCached) {
+        ($problemData) = &ExtractStudentData(\%cache, $students);
         &CalculateStatistics($problemData, \%cache);
-        untie(%cache);
+    }
+    untie(%cache);
 
-        unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
-            $r->print('Unable to tie database.');
-            return ('ERROR', undef);
-        }
+    unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+        $r->print('Unable to tie database.4');
+        return ('ERROR', undef);
+    }
+    if($isNotCached) {
         foreach(keys(%$problemData)) {
             $cache{$_} = $problemData->{$_};
         }
@@ -128,18 +139,20 @@
         $cache{'StatisticsCached'} = 'true';
         $cache{'StatisticsLastStatus'} = $cache{'Status'};
         $cache{'StatisticsWhichStudents'} = $whichStudents;
-        untie(%cache);
+    }
+    untie(%cache);
 
-        unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-            $r->print('Unable to tie database.');
-            return ('ERROR', undef);
-        }
+    unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+        $r->print('Unable to tie database.5');
+        return ('ERROR', undef);
     }
 
     my $orderedProblems = &SortProblems(\%cache, 
                                         $cache{'ProblemStatisticsSort'},
                                         $cache{'SortProblems'},
                                         $cache{'ProblemStatisticsAscend'});
+    untie(%cache);
+
     return ('OK', $orderedProblems);
 }
 
@@ -153,7 +166,7 @@
     my %cache;
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database.');
+        $r->print('Unable to tie database.6');
         return;
     }
     my $Ptr = '';
@@ -197,7 +210,7 @@
     }
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database.');
+        $r->print('Unable to tie database.6');
         return;
     }
     &BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, 
@@ -220,7 +233,7 @@
     }
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        return 'Unable to tie database.';
+        return 'Unable to tie database.7';
     }
    
     my @problems = split(':::', $cache{'problemList'});

--stredwic1029361911--