--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/11/17 19:55:41 1.30
+++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/12/08 19:43:03 1.32
@@ -1,5 +1,5 @@
#
-# $Id: Spreadsheet.pm,v 1.30 2003/11/17 19:55:41 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.32 2003/12/08 19:43:03 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".
''.&mt('Output Format').' |
'."\n".
- ''.&output_selector()." |
\n".
+ ''.$self->output_selector()." |
\n".
"
\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,10 +1423,24 @@ 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) = @_;
my $connection = $r->connection();
+ #
+ $r->print($self->html_report_error());
+ $r->rflush();
+ #
$r->print("".&mt('Preparing Excel Spreadsheet')."
");
#
# Create excel worksheet
@@ -1451,6 +1483,10 @@ sub outsheet_csv {
my $self = shift;
my ($r) = @_;
my $connection = $r->connection();
+ #
+ $r->print($self->html_report_error());
+ $r->rflush();
+ #
my $csvdata = '';
my @Values;
#