--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/05/23 19:36:04 1.5 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/05/23 21:03:29 1.6 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.5 2003/05/23 19:36:04 matthew Exp $ +# $Id: Spreadsheet.pm,v 1.6 2003/05/23 21:03:29 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1342,6 +1342,65 @@ sub outsheet_excel { return; } +################################# +## CSV output routines ## +################################# +sub outsheet_csv { + my $self = shift; + my ($r) = @_; + my $csvdata = ''; + my @Values; + # + # Open the csv file + my $filename = '/prtspool/'. + $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. + time.'_'.rand(1000000000).'.csv'; + my $file; + unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) { + $r->log_error("Couldn't open $filename for output $!"); + $r->print("Problems occured in writing the csv file. ". + "This error has been logged. ". + "Please alert your LON-CAPA administrator."); + $r->print("
\n".$csvdata."\n"); + return 0; + } + # + # Output the title information + foreach my $value ($self->get_title()) { + print $file "'".&Apache::loncommon::csv_translate($value)."'\n"; + } + # + # Output the body of the spreadsheet + $self->csv_rows($file); + # + # Close the csv file + close($file); + $r->print('