--- loncom/interface/spreadsheet/studentcalc.pm 2003/07/16 15:57:32 1.14 +++ loncom/interface/spreadsheet/studentcalc.pm 2003/12/05 22:24:20 1.16.2.1 @@ -1,5 +1,5 @@ # -# $Id: studentcalc.pm,v 1.14 2003/07/16 15:57:32 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; @@ -411,7 +415,6 @@ sub outsheet_recursive_excel { sub compute { my $self = shift; - $self->logthis('computing'); if (! defined($current_course) || $current_course ne $ENV{'request.course.id'}) { $current_course = $ENV{'request.course.id'}; @@ -453,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; @@ -582,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')).':'; @@ -589,7 +603,7 @@ sub save_export_data { my $newstore = join('___;___', @{$Exportrows{$student}->{'data'}}); $newstore = '___=___'.$newstore; - &Apache::lonnet::put('nohist_calculatedsheets', + my $result= &Apache::lonnet::put('nohist_calculatedsheets', { $key => $newstore, $timekey => $Exportrows{$student}->{'time'} }, $self->{'cdom'}, @@ -615,12 +629,24 @@ sub export_data { my $self = shift; my $student = $self->{'name'}.':'.$self->{'domain'}; if (! exists($Exportrows{$student}) || + ! defined($Exportrows{$student}) || + ! exists($Exportrows{$student}->{'data'}) || + ! defined($Exportrows{$student}->{'data'}) || + ! exists($Exportrows{$student}->{'time'}) || + ! defined($Exportrows{$student}->{'time'}) || ! $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; }