--- loncom/interface/spreadsheet/studentcalc.pm 2003/08/01 13:33:41 1.16 +++ loncom/interface/spreadsheet/studentcalc.pm 2003/12/05 22:24:20 1.16.2.1 @@ -1,5 +1,5 @@ # -# $Id: studentcalc.pm,v 1.16 2003/08/01 13:33:41 matthew Exp $ +# $Id: studentcalc.pm,v 1.16.2.1 2003/12/05 22:24:20 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -174,6 +174,10 @@ sub outsheet_html { my $editing_is_allowed = &Apache::lonnet::allowed('mgr', $ENV{'request.course.id'}); #################################### + # Report any calculation errors # + #################################### + $r->print($self->html_report_error()); + #################################### # Determine table structure # #################################### my $num_uneditable = 26; @@ -452,6 +456,12 @@ sub compute { $assess_filename, $resource->{'symb'}); my @exportdata = $assessSheet->export_data(); + if ($assessSheet->badcalc()) { + $self->set_calcerror( + 'Error computing row for assessment '. + $assessSheet->get_title().'(row '.$rownum.'):'. + $assessSheet->calcerror()); + } if ($assessSheet->blackout()) { $self->blackout(1); $self->{'blackout_rows'}->{$rownum} = 1; @@ -581,6 +591,11 @@ sub save_export_data { my $self = shift; return if ($self->temporary()); my $student = $self->{'name'}.':'.$self->{'domain'}; + if ($self->badcalc()){ + # do not save data away when calculations have not been done properly. + delete($Exportrows{$student}); + return; + } return if (! exists($Exportrows{$student})); return if (! $self->is_default()); my $key = join(':',($self->{'name'},$self->{'domain'},'studentcalc')).':'; @@ -622,9 +637,16 @@ sub export_data { ! $self->check_expiration_time($Exportrows{$student}->{'time'})) { $self->compute(); } - my @Data = @{$Exportrows{$student}->{'data'}}; - for (my $i=0; $i<=$#Data;$i++) { - $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i])); + my @Data; + if ($self->badcalc()) { + @Data = (); + } else { + @Data = @{$Exportrows{$student}->{'data'}}; + for (my $i=0; $i<=$#Data;$i++) { + if ($Data[$i]=~/\D/ && defined($Data[$i])) { + $Data[$i]="'".$Data[$i]."'"; + } + } } return @Data; }