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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 02 Jun 2003 16:57:41 -0000


matthew		Mon Jun  2 12:57:41 2003 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  Address Bug 1538 (read it for a description) in two ways by 
     a) deleting ALL the tables associated with a cache if any one is missing.
     b) storing the part as well as the part_id in the performance table.
  Thus if the part_id table goes missing we should either remove all the other
  tables and begin caching again or, if that does not occur, be able to serve
  up all the data anyway.  This is an improvement over the current behavior.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.72 loncom/interface/loncoursedata.pm:1.73
--- loncom/interface/loncoursedata.pm:1.72	Tue May 27 11:48:12 2003
+++ loncom/interface/loncoursedata.pm	Mon Jun  2 12:57:41 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.72 2003/05/27 15:48:12 matthew Exp $
+# $Id: loncoursedata.pm,v 1.73 2003/06/02 16:57:41 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -455,6 +455,13 @@
     my $courseid = shift;
     &setup_table_names($courseid);
     #
+    # Drop any of the existing tables
+    foreach my $table ($symb_table,$part_table,$student_table,
+                       $updatetime_table,$performance_table,
+                       $parameters_table) {
+        &Apache::lonmysql::drop_table($table);
+    }
+    #
     # Note - changes to this table must be reflected in the code that 
     # stores the data (calls &Apache::lonmysql::store_row with this table
     # id
@@ -527,6 +534,9 @@
                     { name => 'part_id',
                       type => 'MEDIUMINT UNSIGNED',
                       restrictions => 'NOT NULL' },
+                    { name => 'part',
+                      type => 'VARCHAR(100)',
+                      restrictions => 'NOT NULL'},                    
                     { name => 'solved',
                       type => 'TINYTEXT' },
                     { name => 'tries',
@@ -950,7 +960,7 @@
             $awarded     = '' if (! defined($awarded));
             $award       = '' if (! defined($award));
             $awarddetail = '' if (! defined($awarddetail));
-            $newstring = "('".join("','",$symb_id,$student_id,$part_id,
+            $newstring = "('".join("','",$symb_id,$student_id,$part_id,$part,
                                    $solved,$tries,$awarded,$award,
                                    $awarddetail,$timestamp)."'),\n";
             $store_performance_command .= $newstring;
@@ -1094,12 +1104,12 @@
     #
     my $dbh = &Apache::lonmysql::get_dbh();
     my $request = "SELECT ".
-        "d.symb,c.part,a.solved,a.tries,a.awarded,a.award,a.awarddetail,".
+        "d.symb,a.part,a.solved,a.tries,a.awarded,a.award,a.awarddetail,".
             "a.timestamp ";
     if (defined($student)) {
         $request .= "FROM $student_table AS b ".
             "LEFT JOIN $performance_table AS a ON b.student_id=a.student_id ".
-            "LEFT JOIN $part_table AS c ON c.part_id = a.part_id ".
+#            "LEFT JOIN $part_table AS c ON c.part_id = a.part_id ".
             "LEFT JOIN $symb_table AS d ON d.symb_id = a.symb_id ".
                 "WHERE student='$student'";
         if (defined($symb) && $symb ne '') {
@@ -1108,7 +1118,7 @@
     } elsif (defined($symb) && $symb ne '') {
         $request .= "FROM $symb_table as d ".
             "LEFT JOIN $performance_table AS a ON d.symb_id=a.symb_id ".
-            "LEFT JOIN $part_table    AS c ON c.part_id = a.part_id ".
+#            "LEFT JOIN $part_table    AS c ON c.part_id = a.part_id ".
             "LEFT JOIN $student_table AS b ON b.student_id = a.student_id ".
                 "WHERE symb='".$dbh->quote($symb)."'";
     }
@@ -1191,6 +1201,12 @@
          ' domain = '.$sdom.
          ' status = '.$status.
          ' data is '.(defined($data)?'defined':'undefined'));
+#    while (my ($symb,$hash) = each(%$data)) {
+#        &Apache::lonnet::logthis($symb."\n----------------------------------");
+#        while (my ($key,$value) = each (%$hash)) {
+#            &Apache::lonnet::logthis("   ".$key." = ".$value);
+#        }
+#    }
     #
     if (defined($data)) {
         if (defined($symb)) {