--- loncom/interface/spreadsheet/studentcalc.pm 2003/12/05 22:24:20 1.16.2.1 +++ loncom/interface/spreadsheet/studentcalc.pm 2003/09/05 01:06:45 1.17 @@ -1,5 +1,5 @@ # -# $Id: studentcalc.pm,v 1.16.2.1 2003/12/05 22:24:20 matthew Exp $ +# $Id: studentcalc.pm,v 1.17 2003/09/05 01:06:45 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,6 +45,9 @@ studentcalc ################################################### package Apache::studentcalc; +use warnings FATAL=>'all'; +no warnings 'uninitialized'; + use strict; use Apache::Constants qw(:common :http); use Apache::lonnet; @@ -98,8 +101,8 @@ sub initialize_sequence_cache { } sub clear_package { - @Sequences = undef; - %Exportrows = undef; + undef(@Sequences); + undef(%Exportrows); } sub get_title { @@ -174,10 +177,6 @@ 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; @@ -456,12 +455,6 @@ 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; @@ -503,7 +496,7 @@ sub compute { sub set_row_sources { my $self = shift; while (my ($cell,$value) = each(%{$self->{'formulas'}})) { - next if ($cell !~ /^A(\d+)/ && $1 > 0); + next if ($cell !~ /^A(\d+)$/ || $1 < 1); my $row = $1; (undef,$value) = split('__&&&__',$value); $value = 'Default' if (! defined($value)); @@ -520,7 +513,7 @@ sub set_row_numbers { next if ($row == 0); my ($symb,undef) = split('__&&&__',$formula); $self->{'row_numbers'}->{$symb} = $row; - $self->{'maxrow'} = $1 if ($1 > $self->{'maxrow'}); + $self->{'maxrow'} = $row if ($row > $self->{'maxrow'}); } } @@ -550,7 +543,7 @@ These rows are saved in the courses dire ############################################# ############################################# sub load_cached_export_rows { - %Exportrows = undef; + undef(%Exportrows); my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); @@ -591,11 +584,6 @@ 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')).':'; @@ -637,16 +625,9 @@ sub export_data { ! $self->check_expiration_time($Exportrows{$student}->{'time'})) { $self->compute(); } - 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]."'"; - } - } + my @Data = @{$Exportrows{$student}->{'data'}}; + for (my $i=0; $i<=$#Data;$i++) { + $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i])); } return @Data; }