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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 06 Mar 2003 21:12:54 -0000


matthew		Thu Mar  6 16:12:54 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  Use lonhtmlcommon progress windows.
  
  
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.35 loncom/interface/statistics/lonstudentassessment.pm:1.36
--- loncom/interface/statistics/lonstudentassessment.pm:1.35	Wed Mar  5 15:31:13 2003
+++ loncom/interface/statistics/lonstudentassessment.pm	Thu Mar  6 16:12:54 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.35 2003/03/05 20:31:13 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.36 2003/03/06 21:12:54 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -656,8 +656,7 @@
 my $rows_output;
 my $cols_output;
 
-my $num_students;
-my $start_time;
+my %prog_state; # progress window state
 
 sub excel_initialize {
     my ($r) = @_;
@@ -672,9 +671,6 @@
     $rows_output = 0;
     $cols_output = 0;
     #
-    $num_students = 0;
-    $start_time   = time;
-    #
     # Create sheet
     $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
     #
@@ -764,6 +760,11 @@
     $r->print("</h1>\n");
     $r->rflush();
     #
+    # Initialize progress window
+    %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
+        ($r,'Excel File Compilation Status',
+         'Excel File Compilation Progress', $studentcount);
+    #
     return;
 }
 
@@ -805,31 +806,8 @@
     $rows_output++; 
     $cols_output=0;
     #
-    # Time estimate
-    $num_students++;
-    if ($num_students % 10 == 0) {
-        my $time_est = (time - $start_time)/$num_students * 
-            (scalar(@Apache::lonstatistics::Students)-$num_students);
-        $time_est = int($time_est);
-        if (int ($time_est/60) > 0) {
-            my $min = int($time_est/60);
-            my $sec = $time_est % 60;
-            $time_est = $min.' minutes';
-            if ($sec > 1) {
-                $time_est.= ', '.$sec.' seconds';
-            } elsif ($sec > 0) {
-                $time_est.= ', '.$sec.' second';
-            }
-        } else {
-            $time_est .= ' seconds';
-        }
-        $r->print($num_students.' out of '.
-                  (scalar(@Apache::lonstatistics::Students)).
-                  " students processed.  ".
-                  $time_est." remain.  Elapsed: ".(time - $start_time).
-                  "<br />\n");
-        $r->rflush();
-    }
+    # Update the progress window
+    &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
     return;
 }
 
@@ -843,14 +821,12 @@
     #
     return if($c->aborted());
     #
+    # Close the progress window
+    &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+    #
     # Tell the user where to get their excel file
-    $r->print('<br /><br />'.
+    $r->print('<br />'.
               '<a href="'.$filename.'">Your Excel spreadsheet.</a>'."\n");
-    my $total_time = time - $start_time;
-    if (int ($total_time / 60) > 0) {
-        $total_time = int($total_time/60).' minutes, '.($total_time % 60);
-    }
-    $r->print('<br />'.$total_time.' seconds total');
     $r->rflush();
     return;
 }