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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 22 Jul 2004 15:55:57 -0000


matthew		Thu Jul 22 11:55:57 2004 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  &get_sum_of_scores: Added checks on validity of $students input.
  Modified error logging code in various subroutines to give unique error
  messages so I can tell where the messages came from and what was going
  on when they occured.  I do not believe this will lead to a signifignant
  increase in the size of the log files.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.137 loncom/interface/loncoursedata.pm:1.138
--- loncom/interface/loncoursedata.pm:1.137	Tue Jul  6 11:50:03 2004
+++ loncom/interface/loncoursedata.pm	Thu Jul 22 11:55:57 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.137 2004/07/06 15:50:03 matthew Exp $
+# $Id: loncoursedata.pm,v 1.138 2004/07/22 15:55:57 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2303,6 +2303,14 @@
     if (! defined($courseid)) {
         $courseid = $ENV{'request.course.id'};
     }
+    if (defined($students) && 
+        ((@$students == 0) ||
+         (@$students == 1 && (! defined($students->[0]) || 
+                              $students->[0] eq ''))
+         )
+        ){
+        undef($students);
+    }
     #
     &setup_table_names($courseid);
     my $dbh = &Apache::lonmysql::get_dbh();
@@ -2325,7 +2333,9 @@
     $sth->execute();
     my $rows = $sth->fetchrow_arrayref();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 1 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed, fetchrow_arrayrefed'.
+                                 $/.$request);
         return (undef,undef);
     }
     return ($rows->[0],$rows->[1]);
@@ -2505,7 +2515,8 @@
     my $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 2 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     my $dataset = $sth->fetchall_arrayref();
@@ -2574,7 +2585,8 @@
     my $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 3 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     my $dataset = $sth->fetchall_arrayref();
@@ -2630,7 +2642,8 @@
     my $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 4 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     my $dataset = $sth->fetchall_arrayref();
@@ -2682,7 +2695,8 @@
     my $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 5 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     my $dataset = $sth->fetchall_arrayref();
@@ -2772,7 +2786,8 @@
     my $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 6 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     $request = 'SELECT score,COUNT(*) FROM '.$tmptable.' GROUP BY score';
@@ -2780,7 +2795,8 @@
     $sth = $dbh->prepare($request);
     $sth->execute();
     if ($dbh->err) {
-        &Apache::lonnet::logthis('error = '.$dbh->errstr());
+        &Apache::lonnet::logthis('error 7 = '.$dbh->errstr());
+        &Apache::lonnet::logthis('prepared then executed '.$/.$request);
         return undef;
     }
     my $dataset = $sth->fetchall_arrayref();