--- loncom/interface/statistics/lonstudentassessment.pm 2004/01/27 16:04:27 1.80
+++ loncom/interface/statistics/lonstudentassessment.pm 2004/02/10 16:47:25 1.84
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentassessment.pm,v 1.80 2004/01/27 16:04:27 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.84 2004/02/10 16:47:25 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -785,22 +785,20 @@ sub StudentAverageTotal {
$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 .= '
'.$seq->{'title'}.' | '.
- ''.$ave.' | '.
- ''.$max.' |
'."\n";
+ ''.$ave.' | '.
+ ''.$max.' '.' | '."\n";
}
- $total_ave = int(100*$total_ave)/100; # only two digit
+ $total_ave = sprintf('%.2f',$total_ave); # only two digit
$Str .= "\n";
$Str .= ''."\n";
$Str .= 'Number of Students | Average | '.
"Maximum |
\n";
- $Str .= ''.($num_students-$nodata_count).' | '.
- ''.$total_ave.' | '.$total_max.' | ';
+ $Str .= '
'.
+ ''.($num_students-$nodata_count).' | '.
+ ''.$total_ave.' '.' | '.
+ ''.$total_max.' '.' | ';
$Str .= "
\n";
return $Str;
}
@@ -1016,8 +1014,14 @@ END
($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 ($res->{'type'} ne 'assessment' ||
+ ! exists($res->{'parts'}) ||
+ ref($res->{'parts'}) ne 'ARRAY' ||
+ scalar(@{$res->{'parts'}}) < 1) {
+ next;
+ }
if (scalar(@{$res->{'parts'}}) > 1) {
foreach my $part (@{$res->{'parts'}}) {
$excel_sheet->write($rows_output,
@@ -1029,13 +1033,23 @@ END
$cols_output++,
$res->{'title'});
}
+ $count++;
}
# Determine ending cell
- $seq->{'Excel:endcell'} =
- &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
- ($rows_output,$cols_output-1);
- $seq->{'Excel:endcol'}=$cols_output-1;
+ if ($count == 1) {
+ $seq->{'Excel:endcell'} = $seq->{'Excel:startcell'};
+ $seq->{'Excel:endcol'} = $seq->{'Excel:startcol'};
+ } else {
+ $seq->{'Excel:endcell'} =
+ &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
+ ($rows_output,$cols_output-1);
+ $seq->{'Excel:endcol'} = $cols_output-1;
+ }
# Create the formula for summing up this sequence
+ if (! exists($seq->{'Excel:endcell'}) ||
+ ! defined($seq->{'Excel:endcell'})) {
+ $seq->{'Excel:endcell'} = $seq->{'Excel:startcell'};
+ }
$seq->{'Excel:sum'}= $excel_sheet->store_formula
('=SUM('.$seq->{'Excel:startcell'}.
':'.$seq->{'Excel:endcell'}.')');
@@ -1207,9 +1221,15 @@ sub excel_outputstudent {
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
($rows_output,$seq->{'Excel:endcol'});
# The undef is for the format
- $excel_sheet->repeat_formula($rows_output,$cols_output++,
- $seq->{'Excel:sum'},undef,
- %replaceCells);
+ if (scalar(keys(%replaceCells)) == 1) {
+ $excel_sheet->repeat_formula($rows_output,$cols_output++,
+ $seq->{'Excel:sum'},undef,
+ %replaceCells,%replaceCells);
+ } else {
+ $excel_sheet->repeat_formula($rows_output,$cols_output++,
+ $seq->{'Excel:sum'},undef,
+ %replaceCells);
+ }
#
$excel_sheet->write($rows_output,$cols_output++,$seq_max);
} elsif ($data eq 'sum and total' || $data eq 'sum only' ||