--- loncom/interface/spreadsheet/Spreadsheet.pm 2008/09/12 14:35:46 1.80 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2014/02/12 16:54:21 1.83 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.80 2008/09/12 14:35:46 bisitz Exp $ +# $Id: Spreadsheet.pm,v 1.83 2014/02/12 16:54:21 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -726,7 +726,7 @@ sub get_values { my @num=($ld..$ud); foreach my $a (@alpha) { foreach my $n (@num) { - if (exists($sheet_values{$a.$n})) { + if ((exists($sheet_values{$a.$n})) && ($sheet_values{$a.$n} ne '')) { push(@values,$sheet_values{$a.$n}); } } @@ -742,8 +742,10 @@ sub get_values { $alpha=qq/[$la-$ua]/; } my $expression = '^'.$alpha.$num.'$'; - foreach (grep /$expression/,keys(%sheet_values)) { - push(@values,$sheet_values{$_}); + foreach my $item (grep(/$expression/,keys(%sheet_values))) { + unless ($sheet_values{$item} eq '') { + push(@values,$sheet_values{$item}); + } } return \@values; } @@ -772,7 +774,7 @@ sub calc { $depth++; if ($depth>100) { undef %sheet_values; - return $lastcalc.': Maximum calculation depth exceeded'; + return $lastcalc.': '.&mt('Maximum calculation depth exceeded'); } } return 'okay'; @@ -871,7 +873,7 @@ sub expandnamed { $returnvalue = $values[0]; } elsif (scalar(@matches) > 0) { # more than one match. Look for a concise one - $returnvalue = "'non-unique parameter name : $expression'"; + $returnvalue = "'".&mt('non-unique parameter name: [_1]',$expression).'"'; for (my $i=0; $i<=$#matches;$i++) { if ($matches[$i] =~ /^$expression$/) { # why do we not do this lookup here? @@ -881,7 +883,7 @@ sub expandnamed { } else { # There was a negative number of matches, which indicates # something is wrong with reality. Better warn the user. - $returnvalue = '"bizzare parameter: '.$expression.'"'; + $returnvalue = "'".&mt('bizzare parameter: [_1]',$expression)."'"; } return $returnvalue; } @@ -1265,9 +1267,9 @@ sub html_report_error { my $self = shift(); my $Str = ''; if ($self->badcalc()) { - $Str = '

'. + $Str = '

'. &mt('An error occurred while calculating this spreadsheet'). - "

\n". + "

\n". '
'.$self->calcerror()."
\n"; } return $Str; @@ -1430,7 +1432,7 @@ sub output_selector { foreach ($self->output_options()) { $output_selector.='\n"; } @@ -1507,7 +1509,7 @@ sub outsheet_excel { # # Write a link to allow them to download it $r->print('
'. - 'Your Excel spreadsheet.'."\n"); + ''.&mt('Your Excel spreadsheet').''."\n"); return; } @@ -1532,9 +1534,13 @@ sub outsheet_csv { my $file; unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) { $r->log_error("Couldn't open $filename for output $!"); - $r->print(&mt('Problems occurred in writing the CSV file. ' - .'This error has been logged. ' - .'Please alert your LON-CAPA administrator.')); + $r->print( + '

' + .&mt('Problems occurred in writing the CSV file.') + .' '.&mt('This error has been logged.') + .' '.&mt('Please alert your LON-CAPA administrator.') + .'

' + ); $r->print("
\n".$csvdata."
\n"); return 0; } @@ -1689,8 +1695,10 @@ sub load { my $sheetxml=&Apache::lonnet::getfile (&Apache::lonnet::filelocation('',$filename)); if ($sheetxml == -1) { - $sheetxml='"Error loading spreadsheet ' - .$self->filename().'"'; + $sheetxml=''. + &mt('Error loading spreadsheet [_1]', + '"'.$self->filename().'"'). + ''; } ($formulas,undef) = &parse_sheet(\$sheetxml); # Get just the filename and set the sheets filename