--- loncom/interface/Attic/lonspreadsheet.pm 2002/11/21 19:26:34 1.147
+++ loncom/interface/Attic/lonspreadsheet.pm 2002/12/04 21:49:33 1.154
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.147 2002/11/21 19:26:34 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;
@@ -965,11 +966,9 @@ sub templaterow {
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z') {
- my $fm=$sheet->{'f'}->{'template_'.$_};
- $fm=~s/[\'\"]/\&\#34;/g;
push(@cols,{ name => 'template_'.$_,
- formula => $fm,
- value => $fm });
+ formula => $sheet->{'f'}->{'template_'.$_},
+ value => $sheet->{'f'}->{'template_'.$_} });
}
return ($rowlabel,@cols);
}
@@ -982,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 = '';
}
@@ -993,10 +996,8 @@ sub outrowassess {
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z') {
- my $fm=$sheet->{'f'}->{$_.$n};
- $fm=~s/[\'\"]/\&\#34;/g;
push(@cols,{ name => $_.$n,
- formula => $fm,
+ formula => $sheet->{'f'}->{$_.$n},
value => $sheet->{'values'}->{$_.$n}});
}
return ($rowlabel,@cols);
@@ -1019,10 +1020,8 @@ sub outrow {
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z') {
- my $fm=$sheet->{'f'}->{$_.$n};
- $fm=~s/[\'\"]/\&\#34;/g;
push(@cols,{ name => $_.$n,
- formula => $fm,
+ formula => $sheet->{'f'}->{$_.$n},
value => $sheet->{'values'}->{$_.$n}});
}
return ($rowlabel,@cols);
@@ -1203,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;
@@ -1253,19 +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);
}
+ # 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;
- $result .= ''.$value.'';
+ # Glue everything together
+ $result .= "".$value."";
return $result;
}
sub html_uneditable_cell {
my ($cell,$bgcolor) = @_;
my $value = (defined($cell) ? $cell->{'value'} : '');
+ $value = &HTML::Entities::encode($value);
return ' '.$value.' ';
}
@@ -1317,7 +1329,7 @@ END
# Print out template row
####################################
my ($rowlabel,@rowdata) = &get_row($sheet,'-');
- my $row_html = '
'.&format_html_rowlabel($rowlabel).'
';
+ my $row_html = '
'.&format_html_rowlabel($sheet,$rowlabel).'
';
my $num_cols_output = 0;
foreach my $cell (@rowdata) {
if ($num_cols_output++ < $num_uneditable) {
@@ -1334,8 +1346,8 @@ END
####################################
# Print out summary/export row
####################################
- my ($rowlabel,@rowdata) = &get_row($sheet,'0');
- $row_html = '
';
$num_cols_output = 0;
foreach my $cell (@rowdata) {
if ($num_cols_output++ < 26) {
@@ -1381,25 +1393,28 @@ END
'';
#
if ($sheet->{'sheettype'} eq 'classcalc') {
- $row_html.='
'.&format_html_rowlabel($rowlabel).'
';
+ $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') {
- $row_html.='
'.&format_html_rowlabel($rowlabel);
+ my $ufn = (split(/:/,$rowlabel))[5];
+ $row_html.='