--- loncom/interface/Attic/lonspreadsheet.pm 2002/12/02 16:39:30 1.151
+++ loncom/interface/Attic/lonspreadsheet.pm 2002/12/04 21:49:33 1.154
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.151 2002/12/02 16:39:30 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.154 2002/12/04 21:49:33 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,6 +62,7 @@ use Safe;
use Safe::Hole;
use Opcode;
use GDBM_File;
+use HTML::Entities();
use HTML::TokeParser;
use Spreadsheet::WriteExcel;
@@ -980,7 +981,11 @@ sub outrowassess {
if ($n) {
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n});
if (exists($sheet->{'rowlabel'}->{$usy})) {
- $rowlabel = $sheet->{'rowlabel'}->{$usy};
+ # This is dumb, but we need the information when we output
+ # the html version of the studentcalc spreadsheet for the
+ # links to the assesscalc sheets.
+ $rowlabel = $sheet->{'rowlabel'}->{$usy}.':'.
+ &Apache::lonnet::escape($ufn);
} else {
$rowlabel = '';
}
@@ -1197,9 +1202,13 @@ sub sort_indicies {
my @sortby2=(undef);
# Skip row 0
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) {
- my (undef,$symb,$uname,$udom,$mapid,$resid,$title) =
- split(':',$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$row}});
- $symb = &Apache::lonnet::unescape($symb);
+ my ($key,undef) = split(/__&&&\__/,$sheet->{'f'}->{'A'.$row});
+ my $rowlabel = $sheet->{'rowlabel'}->{$key};
+ my (undef,$symb,$mapid,$resid,$title,$ufn) =
+ split(':',$rowlabel);
+ $ufn = &Apache::lonnet::unescape($ufn);
+ $symb = &Apache::lonnet::unescape($symb);
+ $title = &Apache::lonnet::unescape($title);
my ($sequence) = ($symb =~ /\/([^\/]*\.sequence)/);
if ($sequence eq '') {
$sequence = $symb;
@@ -1247,27 +1256,28 @@ sub html_editable_cell {
if ($formula ne '') {
$value = 'undefined value';
}
- }
- if ($value =~ /^\s*$/ ) {
+ } elsif ($value =~ /^\s*$/ ) {
$value = '#';
+ } else {
+ $value = &HTML::Entities::encode($value);
}
- &Apache::lonnet::logthis($name.' formula = '.$formula) if ($formula);
- $formula =~ s/\</g;
- $formula =~ s/>/\>/g;
- $formula =~ s/\&/\&/g;
- $formula =~ s/\"/\"/g;
- $formula =~ s/\'/\"/g;
+ # Make the formula safe for outputting
+ $formula =~ s/\'/\"/g;
+ # The formula will be parsed by the browser *twice* before being
+ # displayed to the user for editing.
+ $formula = &HTML::Entities::encode(&HTML::Entities::encode($formula));
+ # Escape newlines so they make it into the edit window
$formula =~ s/\n/\\n/gs;
- &Apache::lonnet::logthis($name.' formula = '.$formula) if ($formula);
+ # Glue everything together
$result .= "".$value."";
- &Apache::lonnet::logthis('result = '.$result) if ($formula);
return $result;
}
sub html_uneditable_cell {
my ($cell,$bgcolor) = @_;
my $value = (defined($cell) ? $cell->{'value'} : '');
+ $value = &HTML::Entities::encode($value);
return ' '.$value.' ';
}
@@ -1336,7 +1346,7 @@ END
####################################
# Print out summary/export row
####################################
- my ($rowlabel,@rowdata) = &get_row($sheet,'0');
+ ($rowlabel,@rowdata) = &get_row($sheet,'0');
$row_html = '
'.&format_html_rowlabel($sheet,$rowlabel).'
';
$num_cols_output = 0;
foreach my $cell (@rowdata) {
@@ -1385,18 +1395,21 @@ END
if ($sheet->{'sheettype'} eq 'classcalc') {
$row_html.='
'.&format_html_rowlabel($sheet,$rowlabel).'
';
# Output links for each student?
- # Nope, that is already done for us in format_html_rowlabel (for now)
+ # Nope, that is already done for us in format_html_rowlabel
+ # (for now)
} elsif ($sheet->{'sheettype'} eq 'studentcalc') {
+ my $ufn = (split(/:/,$rowlabel))[5];
$row_html.='