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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 24 Sep 2003 15:14:41 -0000


matthew		Wed Sep 24 11:14:41 2003 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  1. get_sequence_assessment_data now stores away response id and type data.
  2. Replaced MySQL table $courseid.'_updatetime' with $courseid.'_studentdata'.
     Added 2 columns, section and classification which are currently unused.
     Changed primary key from student (name:domain) to student_id (unsigned int).
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.86 loncom/interface/loncoursedata.pm:1.87
--- loncom/interface/loncoursedata.pm:1.86	Tue Sep  9 14:46:28 2003
+++ loncom/interface/loncoursedata.pm	Wed Sep 24 11:14:41 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.86 2003/09/09 18:46:28 www Exp $
+# $Id: loncoursedata.pm,v 1.87 2003/09/24 15:14:41 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -191,12 +191,18 @@
         $symb  = $curRes->symb();
         $src   = $curRes->src();
         my $parts = $curRes->parts();
+        my %partdata;
+        foreach my $part (@$parts) {
+            $partdata{$part}->{'ResponseTypes'}= $curRes->responseType($part);
+            $partdata{$part}->{'ResponseIds'}  = $curRes->responseIds($part);
+        }
         my $assessment = { title => $title,
                            src   => $src,
                            symb  => $symb,
                            type  => 'assessment',
                            parts => $parts,
                            num_parts => scalar(@$parts),
+                           partdata => \%partdata,
                        };
         push(@Assessments,$assessment);
         push(@{$currentmap->{'contents'}},$assessment);
@@ -388,12 +394,12 @@
 (stored in the students environment).  This table has its PRIMARY KEY on the
 'student' (100 characters).
 
-=item $updatetime_table
+=item $studentdata_table
 
-The updatetime_table has two columns.  The first is 'student' (100 characters,
-typically username:domain).  The second is 'updatetime', which is an unsigned
-integer, NOT a MySQL date.  This table has its PRIMARY KEY on 'student' (100
-characters).
+The studentdata_table has four columns.  The first is 'student_id', the unique
+id of the student.  The second is the time the students data was last updated.
+The third is the students section.  The fourth is the students current
+classification.  This table has its PRIMARY KEY on 'student_id'.
 
 =item $performance_table
 
@@ -451,7 +457,7 @@
 my $symb_table;
 my $part_table;
 my $student_table;
-my $updatetime_table;
+my $studentdata_table;
 my $performance_table;
 my $parameters_table;
 
@@ -479,7 +485,7 @@
     #
     # Drop any of the existing tables
     foreach my $table ($symb_table,$part_table,$student_table,
-                       $updatetime_table,$performance_table,
+                       $studentdata_table,$performance_table,
                        $parameters_table) {
         &Apache::lonmysql::drop_table($table);
     }
@@ -533,17 +539,21 @@
         'KEY' => [{ columns => ['student_id']},],
     };
     #
-    my $updatetime_table_def = {
-        id => $updatetime_table,
+    my $studentdata_table_def = {
+        id => $studentdata_table,
         permanent => 'no',
-        columns => [{ name => 'student',
-                      type => 'VARCHAR(100)',
+        columns => [{ name => 'student_id',
+                      type => 'MEDIUMINT UNSIGNED',
                       restrictions => 'NOT NULL UNIQUE',},
                     { name => 'updatetime',
                       type => 'INT UNSIGNED',
                       restrictions => 'NOT NULL' },
+                    { name => 'section',
+                      type => 'VARCHAR(100)'},
+                    { name => 'classification',
+                      type => 'VARCHAR(100)', },
                     ],
-        'PRIMARY KEY' => ['student (100)'],
+        'PRIMARY KEY' => ['student_id'],
     };
     #
     my $performance_table_def = {
@@ -620,9 +630,9 @@
         return 3;
     }
     #
-    $tableid = &Apache::lonmysql::create_table($updatetime_table_def);
+    $tableid = &Apache::lonmysql::create_table($studentdata_table_def);
     if (! defined($tableid)) {
-        &Apache::lonnet::logthis("error creating updatetime_table: ".
+        &Apache::lonnet::logthis("error creating studentdata_table: ".
                                  &Apache::lonmysql::get_error());
         return 4;
     }
@@ -662,7 +672,7 @@
     #
     my $dbh = &Apache::lonmysql::get_dbh();
     foreach my $table ($symb_table,$part_table,$student_table,
-                       $updatetime_table,$performance_table,
+                       $studentdata_table,$performance_table,
                        $parameters_table ){
         my $command = 'DROP TABLE '.$table.';';
         $dbh->do($command);
@@ -1000,6 +1010,8 @@
     if ($dbh->err()) {
         &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
         &Apache::lonnet::logthis('command = '.$store_parameters_command);
+        &Apache::lonnet::logthis('rows_stored = '.$rows_stored);
+        &Apache::lonnet::logthis('student_id = '.$student_id);
         $returnstatus = 'error: unable to insert parameters into database';
         return ($returnstatus,\%student_data);
     }
@@ -1013,8 +1025,8 @@
     $elapsed += Time::HiRes::time - $start;
     #
     # Set the students update time
-    &Apache::lonmysql::replace_row($updatetime_table,
-                                   [$student,$time_of_retrieval]);
+    &Apache::lonmysql::replace_row($studentdata_table,
+                                   [$student_id,$time_of_retrieval,undef,undef]);
     return ($returnstatus,\%student_data);
 }
 
@@ -1030,7 +1042,7 @@
 Output: $status, $data
 
 This routine ensures the data for a given student is up to date.  It calls
-&init_dbs() if the tables do not exist.  The $updatetime_table is queried
+&init_dbs() if the tables do not exist.  The $studentdata_table is queried
 to determine the time of the last update.  If the students data is out of
 date, &update_student_data() is called.  The return values from the call
 to &update_student_data() are returned.
@@ -1050,17 +1062,17 @@
     #
     # if the tables do not exist, make them
     my @CurrentTable = &Apache::lonmysql::tables_in_db();
-    my ($found_symb,$found_student,$found_part,$found_update,
+    my ($found_symb,$found_student,$found_part,$found_studentdata,
         $found_performance,$found_parameters);
     foreach (@CurrentTable) {
         $found_symb        = 1 if ($_ eq $symb_table);
         $found_student     = 1 if ($_ eq $student_table);
         $found_part        = 1 if ($_ eq $part_table);
-        $found_update      = 1 if ($_ eq $updatetime_table);
+        $found_studentdata = 1 if ($_ eq $studentdata_table);
         $found_performance = 1 if ($_ eq $performance_table);
         $found_parameters  = 1 if ($_ eq $parameters_table);
     }
-    if (!$found_symb        || !$found_update || 
+    if (!$found_symb        || !$found_studentdata || 
         !$found_student     || !$found_part   ||
         !$found_performance || !$found_parameters) {
         if (&init_dbs($courseid)) {
@@ -1074,9 +1086,9 @@
         ($sdom,$sname,$courseid.'.db',
          $Apache::lonnet::perlvar{'lonUsersDir'});
     #
-    my $student = $sname.':'.$sdom;
-    my @Result = &Apache::lonmysql::get_rows($updatetime_table,
-                                             "student ='$student'");
+    my $student_id = &get_student_id($sname,$sdom);
+    my @Result = &Apache::lonmysql::get_rows($studentdata_table,
+                                             "student_id ='$student_id'");
     my $data = undef;
     if (@Result) {
         $updatetime = $Result[0]->[1];
@@ -1465,7 +1477,7 @@
     $symb_table        = $base_id.'_'.'symb';
     $part_table        = $base_id.'_'.'part';
     $student_table     = $base_id.'_'.'student';
-    $updatetime_table  = $base_id.'_'.'updatetime';
+    $studentdata_table = $base_id.'_'.'studentdata';
     $performance_table = $base_id.'_'.'performance';
     $parameters_table  = $base_id.'_'.'parameters';
     return;