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

stredwic lon-capa-cvs@mail.lon-capa.org
Sat, 31 Aug 2002 19:25:39 -0000


stredwic		Sat Aug 31 15:25:39 2002 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  Still could not find out why the spacing is now off.  I did make it
  so that students without course data display No course data instead 
  of a series of zeros.  I also made it so that sequences that had no
  data didn't just display a zero at the end, but are now blank.
  
  
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.9 loncom/interface/statistics/lonstudentassessment.pm:1.10
--- loncom/interface/statistics/lonstudentassessment.pm:1.9	Sat Aug 31 14:31:15 2002
+++ loncom/interface/statistics/lonstudentassessment.pm	Sat Aug 31 15:25:39 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstudentassessment.pm,v 1.9 2002/08/31 18:31:15 stredwic Exp $
+# $Id: lonstudentassessment.pm,v 1.10 2002/08/31 19:25:39 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 #    $jr = $r;
     my %cache;
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('<html><body>Unable to tie database.</body></html>');
+[5~        $r->print('<html><body>Unable to tie database.</body></html>');
         return;
     }
 
@@ -290,8 +290,7 @@
 
     my $Str = '';
     if(defined($cache->{$name.':error'})) {
-        return '<br><br><br>';
-#        return 'ERROR in student report for '.$name.'<br>';
+        return $Str;
     }
     if($cache->{$name.':error'} =~ /course/) {
         $Str .= '<b><font color="blue">No course data for student </font>';
@@ -299,7 +298,10 @@
         return $Str;
     }
 
+    my $hasVersion = 'false';
+    my $hasFinalData = 'false';
     foreach my $sequence (@$showSequences) {
+        my $hasData = 'false';
         my $characterCount=0;
         foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
             my $problem = $cache->{$problemID.':problem'};
@@ -308,12 +310,15 @@
             # current problem in the correct order and prepare the output links
             foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
                                         ':parts'})) {
-                $characterCount++;
                 if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
-                   $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ') {
+                   $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
+                   $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
                     $Str .= ' ';
+                    $characterCount++;
                     next;
                 }
+                $hasVersion = 'true';
+                $hasData = 'true';
                 $Str .= '<a href="/adm/grades?symb=';
                 $Str .= &Apache::lonnet::escape($problem);
                 $Str .= '&student='.$username.'&domain='.$domain;
@@ -324,7 +329,8 @@
                     $code = $tries;
                 }
                 $Str .= $code;
-                $Str.='</a>';
+                $Str .= '</a>';
+                $characterCount++;
             }
         }
 
@@ -337,7 +343,12 @@
 
 	my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
                                                             ':problemsCorrect'});
-	$Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
+        if($hasData eq 'true') {
+            $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
+            $hasFinalData = 'true';
+        } else {
+            $Str .= '<font color="#007700">   </font>';
+        }
         $Str .= $spacing;
     }
 
@@ -346,8 +357,16 @@
     # a way to dynamically determine the space requirements.
     my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
     my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
-    $Str .= '<font color="#000088">'.$outputProblemsSolved.
+    if($hasFinalData eq 'true') {
+        $Str .= '<font color="#000088">'.$outputProblemsSolved.
 	    ' / '.$outputTotalProblems.'</font>';
+    } else {
+        $Str .= '<font color="#000088">           </font>';
+    }
+
+    if($hasVersion eq 'false') {
+        $Str = '<b><font color="blue">No course data.</font></b>';
+    }
 
     return $Str;
 }