--- loncom/interface/spreadsheet/assesscalc.pm 2003/07/29 05:22:56 1.17 +++ loncom/interface/spreadsheet/assesscalc.pm 2003/12/05 22:24:20 1.17.2.3 @@ -1,5 +1,5 @@ # -# $Id: assesscalc.pm,v 1.17 2003/07/29 05:22:56 albertel Exp $ +# $Id: assesscalc.pm,v 1.17.2.3 2003/12/05 22:24:20 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,6 +48,7 @@ use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::loncommon; use Apache::Spreadsheet; +use Apache::loncoursedata(); use HTML::Entities(); use Spreadsheet::WriteExcel; use GDBM_File; @@ -125,6 +126,7 @@ sub clear_package { sub initialize { &clear_package(); + &Apache::loncoursedata::clear_internal_caches(); } ######################################################## @@ -148,6 +150,7 @@ sub initialize_package { } &load_cached_export_rows(); &load_parameter_caches(); + &Apache::loncoursedata::clear_internal_caches(); } ######################################################## @@ -371,6 +374,10 @@ sub parent_link { sub outsheet_html { my $self = shift; my ($r) = @_; + #################################### + # Report any calculation errors # + #################################### + $r->print($self->html_report_error()); ################################### # Determine table structure ################################### @@ -594,7 +601,10 @@ sub compute { while (my ($parm,$value) = each(%parameters)) { last if ($self->blackout()); next if ($parm !~ /^(parameter_.*)_problemstatus$/); - next if ($parameters{$1.'_answerdate'}blackout(1); @@ -738,13 +748,20 @@ sub export_data { ! defined($Exportrows{$symb}->{$self->{'filename'}})) { $self->compute(); } - my @Data = @{$Exportrows{$symb}->{$self->{'filename'}}}; - if ($Data[0] =~ /^(.*)___=___/) { - $self->{'sheetname'} = $1; - $Data[0] =~ s/^(.*)___=___//; - } - 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{$symb}->{$self->{'filename'}}}; + if ($Data[0] =~ /^(.*)___=___/) { + $self->{'sheetname'} = $1; + $Data[0] =~ s/^(.*)___=___//; + } + for (my $i=0;$i<$#Data;$i++) { + if ($Data[$i]=~/\D/ && defined($Data[$i])) { + $Data[$i]="'".$Data[$i]."'"; + } + } } return @Data; } @@ -767,6 +784,11 @@ sub save_export_data { return if ($self->temporary()); my $student = $self->{'name'}.':'.$self->{'domain'}; my $symb = $self->{'symb'}; + if ($self->badcalc()){ + # do not save data away when calculations have not been done properly. + delete($Exportrows{$symb}); + return; + } if (! exists($Exportrows{$symb}) || ! exists($Exportrows{$symb}->{$self->{'filename'}})) { return;