--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/11/17 19:55:41 1.30 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/11/21 21:51:28 1.31 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.30 2003/11/17 19:55:41 matthew Exp $ +# $Id: Spreadsheet.pm,v 1.31 2003/11/21 21:51:28 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1190,16 +1190,24 @@ sub calcerror { 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(); @@ -1336,11 +1344,24 @@ sub html_header { return '' if (! $ENV{'request.role.adv'}); return "\n". ''."\n". - '\n". + '\n". "
'.&mt('Output Format').'
'.&output_selector()."
'.$self->output_selector()."
\n"; } +## +## Default output types are HTML, Excel, and CSV +sub output_options { + my $self = shift(); + return ({value => 'html', + description => 'HTML'}, + {value => 'excel', + description => 'Excel'}, + {value => 'csv', + description => 'Comma Separated Values'},); +} + sub output_selector { + my $self = shift(); my $output_selector = '\n"; return $output_selector; @@ -1405,6 +1423,16 @@ sub create_excel_spreadsheet { return ($workbook,$filename); } +# +# This routine is just a stub +sub outsheet_htmlclasslist { + my $self = shift; + my ($r) = @_; + $r->print('

'.&mt("This output is not supported").'

'); + $r->rflush(); + return; +} + sub outsheet_excel { my $self = shift; my ($r) = @_;