[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm classcalc.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Mon, 27 Feb 2006 00:56:49 -0000
bowersj2 Sun Feb 26 19:56:49 2006 EDT
Modified files:
/loncom/interface/spreadsheet Spreadsheet.pm classcalc.pm
Log:
Fix bug 4556 by introducing the ability to just view the source of the
spreadsheet, without any computation at all.
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.61 loncom/interface/spreadsheet/Spreadsheet.pm:1.62
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.61 Tue Jan 10 11:38:47 2006
+++ loncom/interface/spreadsheet/Spreadsheet.pm Sun Feb 26 19:56:47 2006
@@ -1,5 +1,5 @@
#
-# $Id: Spreadsheet.pm,v 1.61 2006/01/10 16:38:47 albertel Exp $
+# $Id: Spreadsheet.pm,v 1.62 2006/02/27 00:56:47 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1195,12 +1195,19 @@
last;
}
}
+ $self->{outputmode} = $outputmode;
if ($outputmode eq 'html') {
$self->compute($r);
$self->outsheet_html($r);
} elsif ($outputmode eq 'htmlclasslist') {
# No computation neccessary... This is kludgy
$self->outsheet_htmlclasslist($r);
+ } elsif ($outputmode eq 'source') {
+ # No computation necessary. Rumor has it that this is some
+ # sort of kludge w.r.t. not "computing". It's also
+ # a bit of of a kludge that we call "outsheet_html" and
+ # let the 'outputmode' cause the outputting of source.
+ $self->outsheet_html($r);
} elsif ($outputmode eq 'excel') {
$self->compute($r);
$self->outsheet_excel($r);
@@ -1240,10 +1247,12 @@
foreach my $cell (@rowdata) {
if ($cell->{'name'} =~ /^[A-Z]/) {
$row_html .= '<td bgcolor="'.$color.'">'.
- &html_editable_cell($cell,$color,$allowed).'</td>';
+ &html_editable_cell($cell,$color,$allowed,
+ $self->{outputmode} eq 'source').'</td>';
} else {
$row_html .= '<td bgcolor="#DDCCFF">'.
- &html_editable_cell($cell,'#DDCCFF',$allowed).'</td>';
+ &html_editable_cell($cell,'#DDCCFF',$allowed,
+ $self->{outputmode} eq 'source').'</td>';
}
}
return $row_html;
@@ -1263,14 +1272,15 @@
&html_uneditable_cell($cell,'#FFDDDD',$allowed).'</td>';
} else {
$row_html .= '<td bgcolor="#EOFFDD">'.
- &html_editable_cell($cell,'#EOFFDD',$allowed).'</td>';
+ &html_editable_cell($cell,'#EOFFDD',$allowed,
+ $self->{outputmode} eq 'source').'</td>';
}
}
return $row_html;
}
sub html_editable_cell {
- my ($cell,$bgcolor,$allowed) = @_;
+ my ($cell,$bgcolor,$allowed,$showsource) = @_;
my $result;
my ($name,$formula,$value);
if (defined($cell)) {
@@ -1280,7 +1290,15 @@
}
$name = '' if (! defined($name));
$formula = '' if (! defined($formula));
- if (! defined($value)) {
+ if ($showsource)
+ {
+ if (!defined($formula) || $formula =~ /^\s*$/) {
+ $value = '<font color="'.$bgcolor.'">#</font>';
+ } else {
+ $value = &HTML::Entities::encode($formula, '<>&"');
+ }
+ }
+ elsif (! defined($value)) {
$value = '<font color="'.$bgcolor.'">#</font>';
if ($formula ne '') {
$value = '<i>undefined value</i>';
@@ -1333,7 +1351,8 @@
$row_html .= &html_uneditable_cell($cell,'#FFDDDD');
} else {
$row_html .= '<td bgcolor="#EOFFDD">';
- $row_html .= &html_editable_cell($cell,'#E0FFDD',$allowed);
+ $row_html .= &html_editable_cell($cell,'#E0FFDD',$allowed,
+ $self->{outputmode} eq 'source');
}
$row_html .= '</td>';
}
@@ -1357,6 +1376,8 @@
description => 'HTML'},
{value => 'excel',
description => 'Excel'},
+ {value => 'source',
+ description => 'Show Source'},
# {value => 'xml',
# description => 'XML'},
{value => 'csv',
Index: loncom/interface/spreadsheet/classcalc.pm
diff -u loncom/interface/spreadsheet/classcalc.pm:1.23 loncom/interface/spreadsheet/classcalc.pm:1.24
--- loncom/interface/spreadsheet/classcalc.pm:1.23 Thu Apr 7 02:56:23 2005
+++ loncom/interface/spreadsheet/classcalc.pm Sun Feb 26 19:56:47 2006
@@ -1,5 +1,5 @@
#
-# $Id: classcalc.pm,v 1.23 2005/04/07 06:56:23 albertel Exp $
+# $Id: classcalc.pm,v 1.24 2006/02/27 00:56:47 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -285,6 +285,8 @@
my $self = shift();
return ({value => 'htmlclasslist',
description => 'Student Sheet Links'},
+ {value => 'source',
+ description => 'Show Source'},
{value => 'html',
description => 'HTML'},
{value => 'excel',