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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 21 Apr 2003 15:12:37 -0000


matthew		Mon Apr 21 11:12:37 2003 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm lonstatistics.pm 
  Log:
  Added 'Clear Caches' button to statistics which results in 
  &Apache::loncoursedata::delete_caches() being called.  delete_caches()
  executes a 'drop table' for every table used to do local caching for 
  the given course.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.69 loncom/interface/loncoursedata.pm:1.70
--- loncom/interface/loncoursedata.pm:1.69	Fri Apr 18 15:05:30 2003
+++ loncom/interface/loncoursedata.pm	Mon Apr 21 11:12:37 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.69 2003/04/18 19:05:30 matthew Exp $
+# $Id: loncoursedata.pm,v 1.70 2003/04/21 15:12:37 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -572,6 +572,36 @@
         return 6;
     }
     return 0;
+}
+
+################################################
+################################################
+
+=pod
+
+=item &delete_caches()
+
+=cut
+
+################################################
+################################################
+sub delete_caches {
+    my $courseid = shift;
+    $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+    #
+    &setup_table_names($courseid);
+    #
+    my $dbh = &Apache::lonmysql::get_dbh();
+    foreach my $table ($symb_table,$part_table,$student_table,
+                       $updatetime_table,$performance_table,
+                       $parameters_table ){
+        my $command = 'DROP TABLE '.$table.';';
+        $dbh->do($command);
+        if ($dbh->err) {
+            &Apache::lonnet::logthis($command.' resulted in error: '.$dbh->errstr);
+        }
+    }
+    return;
 }
 
 ################################################
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.66 loncom/interface/lonstatistics.pm:1.67
--- loncom/interface/lonstatistics.pm:1.66	Fri Apr 18 11:50:55 2003
+++ loncom/interface/lonstatistics.pm	Mon Apr 21 11:12:37 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.66 2003/04/18 15:50:55 matthew Exp $
+# $Id: lonstatistics.pm,v 1.67 2003/04/21 15:12:37 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -832,12 +832,17 @@
     #
     $Str .= '<table border="0"><tbody><tr>'."\n";
     $Str .= '<td></td>'."\n";
+    $Str .= '<td></td>'."\n";
     $Str .= '<td align="center"><b>Select a Report</b></td>'."\n";
     $Str .= '<td align="center"><b>Student Status</b></td></tr>'."\n";
     $Str .= '<tr>'."\n";
     #
-    $Str .= '<td align="center"><input type="submit" name="Refresh" ';
-    $Str .= 'value="Update Display" /></td>'."\n";
+    $Str .= '<td align="center">'.
+        '<input type="submit" name="Refresh" value="Update Display" />'.
+            "</td>\n";
+    $Str .= '<td align="center">'.
+        '<input type="submit" name="ClearCache" value="Clear Caches" />'.
+            "</td>\n";
     #
     $Str .= '<td align="center">';
     $Str .= '<select name="reportSelected" >'."\n";
@@ -923,6 +928,11 @@
 </html>
 END
         return;
+    }
+    #
+    # Clean out the caches
+    if (exists($ENV{'form.ClearCache'})) {
+        &Apache::loncoursedata::delete_caches($ENV{'requres.course.id'});
     }
     #
     # Set up the statistics and chart environment