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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jan 2004 19:50:03 -0000


matthew		Tue Jan 27 14:50:03 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  Bug 2628: This will address the bug with the formatting of the values 
  shown for the summary table.
  Also improved the handling of 'score' cells in the Excel output in the
  case where there is only one thing in the sequence.
  
  
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.81 loncom/interface/statistics/lonstudentassessment.pm:1.82
--- loncom/interface/statistics/lonstudentassessment.pm:1.81	Tue Jan 27 11:58:05 2004
+++ loncom/interface/statistics/lonstudentassessment.pm	Tue Jan 27 14:50:03 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.81 2004/01/27 16:58:05 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.82 2004/01/27 19:50:03 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -785,22 +785,20 @@
         $total_ave += $ave;
         my $max = $Statistics->{$seq->{'symb'}}->{'max'};
         $total_max += $max;
-        if ($ave == 0) {
-            $ave = "0.00";
-        }
-        $ave .= ' ';
-        $max .= '   ';
+        $ave = sprintf("%.2f",$ave);
         $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.
-            '<td align="right">'.$ave.'</td>'.
-                '<td align="right">'.$max.'</td></tr>'."\n";
+            '<td align="right">'.$ave.'&nbsp;</td>'.
+            '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
     }
-    $total_ave = int(100*$total_ave)/100; # only two digit
+    $total_ave = sprintf('%.2f',$total_ave); # only two digit
     $Str .= "</table>\n";
     $Str .= '<table border=2 cellspacing="1">'."\n";
     $Str .= '<tr><th>Number of Students</th><th>Average</th>'.
         "<th>Maximum</th></tr>\n";
-    $Str .= '<tr><td>'.($num_students-$nodata_count).'</td>'.
-        '<td>'.$total_ave.'</td><td>'.$total_max.'</td>';
+    $Str .= '<tr>'.
+        '<td align="right">'.($num_students-$nodata_count).'</td>'.
+        '<td align="right">'.$total_ave.'&nbsp;'.'</td>'.
+        '<td align="right">'.$total_max.'&nbsp;'.'</td>';
     $Str .= "</table>\n";
     return $Str;
 }
@@ -1016,6 +1014,7 @@
                 ($rows_output,$cols_output);
             $seq->{'Excel:startcol'}=$cols_output;
             # Put the names of the problems and parts into the sheet
+            my $count = 0;
             foreach my $res (@{$seq->{'contents'}}) {
                 next if ($res->{'type'} ne 'assessment');
                 if (scalar(@{$res->{'parts'}}) > 1) {
@@ -1029,12 +1028,17 @@
                                         $cols_output++,
                                         $res->{'title'});
                 }
+                $count++;
             }
             # Determine ending cell
-            $seq->{'Excel:endcell'} = 
+            if ($count == 1) {
+                $seq->{'Excel:endcell'} = $seq->{'Excel:startcell'};
+                $seq->{'Excel:endcol'}  = $seq->{'Excel:startcol'};
+            } else {
                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
-                                             ($rows_output,$cols_output-1);
-            $seq->{'Excel:endcol'}=$cols_output-1;
+                    ($rows_output,$cols_output-1);
+                $seq->{'Excel:endcol'} = $cols_output-1;
+            }
             # Create the formula for summing up this sequence
             $seq->{'Excel:sum'}= $excel_sheet->store_formula
                                         ('=SUM('.$seq->{'Excel:startcell'}.