--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/11/11 14:17:20 1.29 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/12/08 19:43:03 1.32 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.29 2003/11/11 14:17:20 matthew Exp $ +# $Id: Spreadsheet.pm,v 1.32 2003/12/08 19:43:03 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -678,7 +678,7 @@ sub calc { return $lastcalc.': Maximum calculation depth exceeded'; } } - return ''; + return 'okay'; } # ------------------------------------------- End of "Inside of the safe space" @@ -1139,9 +1139,49 @@ sub calcsheet { # $self->logthis($self->get_errorlog()); %{$self->{'values'}} = %{$self->{'safe'}->varglob('sheet_values')}; # $self->logthis($self->get_errorlog()); + if ($result ne 'okay') { + $self->set_calcerror($result); + } return $result; } +sub set_badcalc { + my $self = shift(); + $self->{'badcalc'} =1; + return; +} + +sub badcalc { + my $self = shift; + if (exists($self->{'badcalc'}) && $self->{'badcalc'}) { + return 1; + } else { + return 0; + } +} + +sub set_calcerror { + my $self = shift; + if (@_) { + $self->set_badcalc(); + if (exists($self->{'calcerror'})) { + $self->{'calcerror'}.="\n".$_[0]; + } else { + $self->{'calcerror'}.=$_[0]; + } + } +} + +sub calcerror { + my $self = shift; + if ($self->badcalc()) { + if (exists($self->{'calcerror'})) { + return $self->{'calcerror'}; + } + } + return; +} + ########################################################### ## ## Output Helpers @@ -1150,16 +1190,24 @@ sub calcsheet { sub display { my $self = shift; my ($r) = @_; - $self->compute($r); my $outputmode = 'html'; - if ($ENV{'form.output_format'} =~ /^(html|excel|csv)$/) { - $outputmode = $ENV{'form.output_format'}; + foreach ($self->output_options()) { + if ($ENV{'form.output_format'} eq $_->{'value'}) { + $outputmode = $_->{'value'}; + last; + } } if ($outputmode eq 'html') { + $self->compute($r); $self->outsheet_html($r); + } elsif ($outputmode eq 'htmlclasslist') { + # No computation neccessary... This is kludgy + $self->outsheet_htmlclasslist($r); } elsif ($outputmode eq 'excel') { + $self->compute($r); $self->outsheet_excel($r); } elsif ($outputmode eq 'csv') { + $self->compute($r); $self->outsheet_csv($r); } $self->cleanup(); @@ -1169,6 +1217,18 @@ sub display { ############################################ ## HTML output routines ## ############################################ +sub html_report_error { + my $self = shift(); + my $Str = ''; + if ($self->badcalc()) { + $Str = '
'.$self->calcerror()."\n"; + } + return $Str; +} + sub html_export_row { my $self = shift(); my ($color) = @_; @@ -1284,11 +1344,24 @@ sub html_header { return '' if (! $ENV{'request.role.adv'}); return "
'.&mt('Output Format').' |
---|
'.&output_selector()." |
'.$self->output_selector()." |