--- loncom/interface/spreadsheet/assesscalc.pm 2003/11/11 15:36:28 1.28
+++ loncom/interface/spreadsheet/assesscalc.pm 2004/02/03 22:44:02 1.32
@@ -1,5 +1,5 @@
#
-# $Id: assesscalc.pm,v 1.28 2003/11/11 15:36:28 matthew Exp $
+# $Id: assesscalc.pm,v 1.32 2004/02/03 22:44:02 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -368,7 +368,7 @@ sub parmval {
sub get_html_title {
my $self = shift;
- my ($assess_title,$name,$time) = $self->get_title();
+ my ($assess_title,$name,$time) = $self->get_full_title();
my $title = '
'.$assess_title.'
'.
''.$name.', '.
&Apache::loncommon::aboutmewrapper
@@ -380,17 +380,21 @@ sub get_html_title {
sub get_title {
my $self = shift;
- my @title = ();
if (($self->{'symb'} eq '_feedback') ||
($self->{'symb'} eq '_evaluation') ||
($self->{'symb'} eq '_discussion') ||
($self->{'symb'} eq '_tutoring')) {
my $assess_title = ucfirst($self->{'symb'});
$assess_title =~ s/^_//;
- push(@title,$assess_title);
+ return $assess_title;
} else {
- push(@title,&Apache::lonnet::gettitle($self->{'symb'}));
+ return &Apache::lonnet::gettitle($self->{'symb'});
}
+}
+
+sub get_full_title {
+ my $self = shift;
+ my @title = ($self->get_title());
# Look up the users identifying information
# Get the users information
my %userenv = &Apache::loncoursedata::GetUserName($self->{'name'},
@@ -415,6 +419,10 @@ sub parent_link {
sub outsheet_html {
my $self = shift;
my ($r) = @_;
+ ####################################
+ # Report any calculation errors #
+ ####################################
+ $r->print($self->html_report_error());
###################################
# Determine table structure
###################################
@@ -523,7 +531,7 @@ sub csv_rows {
# writes the meat of the spreadsheet to an excel worksheet. Called
# by Spreadsheet::outsheet_excel;
my $self = shift;
- my ($filehandle) = @_;
+ my ($connection,$filehandle) = @_;
#
# Write a header row
$self->csv_output_row($filehandle,undef,
@@ -546,12 +554,13 @@ sub excel_rows {
# writes the meat of the spreadsheet to an excel worksheet. Called
# by Spreadsheet::outsheet_excel;
my $self = shift;
- my ($worksheet,$cols_output,$rows_output) = @_;
+ my ($connection,$worksheet,$cols_output,$rows_output) = @_;
+ return if (! ref($worksheet));
#
# Write a header row
$cols_output = 0;
foreach my $value ('Parameter','Description','Value') {
- $worksheet->write($rows_output,$cols_output++,&mt($value));
+ $worksheet->write($rows_output,$cols_output++,$value);
}
$rows_output++;
#
@@ -772,7 +781,10 @@ sub compute {
while (my ($parm,$value) = each(%parameters)) {
my $cell = 'A'.$self->get_row_number_from_key($parm);
$f{$cell} = $parm;
- $value = '"'.$value.'"' if ($value =~/[^0-9.]/);
+ if ($parm =~ /_submission$/ && $value =~ /(\{|\})/) {
+ $value = 'witheld';
+ }
+ $value = 'q{'.$value.'}' if ($value =~/([^\d\.]|\.\.)/);
$c{$parm} = $value;
}
$self->formulas(\%f);
@@ -907,13 +919,20 @@ sub export_data {
$self->compute($r);
}
if ($connection->aborted()) { $self->cleanup(); return; }
- my @Data = @{$Exportrows{$symb}->{$self->{'filename'}}};
- if ($Data[0] =~ /^(.*)___=___/) {
- $self->{'sheetname'} = $1;
- $Data[0] =~ s/^(.*)___=___//;
- }
- for (my $i=0;$i<$#Data;$i++) {
- $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i]));
+ my @Data;
+ if ($self->badcalc()) {
+ @Data = ();
+ } else {
+ @Data = @{$Exportrows{$symb}->{$self->{'filename'}}};
+ if ($Data[0] =~ /^(.*)___=___/) {
+ $self->{'sheetname'} = $1;
+ $Data[0] =~ s/^(.*)___=___//;
+ }
+ for (my $i=0;$i<$#Data;$i++) {
+ if ($Data[$i]=~/\D/ && defined($Data[$i])) {
+ $Data[$i]="'".$Data[$i]."'";
+ }
+ }
}
return @Data;
}
@@ -936,6 +955,11 @@ sub save_export_data {
return if ($self->temporary());
my $student = $self->{'name'}.':'.$self->{'domain'};
my $symb = $self->{'symb'};
+ if ($self->badcalc()){
+ # do not save data away when calculations have not been done properly.
+ delete($Exportrows{$symb});
+ return;
+ }
if (! exists($Exportrows{$symb}) ||
! exists($Exportrows{$symb}->{$self->{'filename'}})) {
return;