--- loncom/interface/Attic/lonspreadsheet.pm 2002/10/22 13:13:15 1.121
+++ loncom/interface/Attic/lonspreadsheet.pm 2002/10/24 14:34:07 1.125
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.121 2002/10/22 13:13:15 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.125 2002/10/24 14:34:07 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -122,20 +122,17 @@ my $tmpdir;
##
sub mask {
my ($lower,$upper)=@_;
-
- $lower=~/([A-Za-z]|\*)(\d+|\*)/;
- my $la=$1;
- my $ld=$2;
-
- $upper=~/([A-Za-z]|\*)(\d+|\*)/;
- my $ua=$1;
- my $ud=$2;
+ #
+ my ($la,$ld) = ($lower=~/([A-Za-z]|\*)(\d+|\*)/);
+ my ($ua,$ud) = ($upper=~/([A-Za-z]|\*)(\d+|\*)/);
+ #
my $alpha='';
my $num='';
-
+ #
if (($la eq '*') || ($ua eq '*')) {
$alpha='[A-Za-z]';
} else {
+
if (($la=~/[A-Z]/) && ($ua=~/[A-Z]/) ||
($la=~/[a-z]/) && ($ua=~/[a-z]/)) {
$alpha='['.$la.'-'.$ua.']';
@@ -188,8 +185,8 @@ sub mask {
}
$num.=')';
} else {
- if ($lda[$#lda]!=$uda[$#uda]) {
- $num.='['.$lda[$#lda].'-'.$uda[$#uda].']';
+ if ($lda[-1]!=$uda[-1]) {
+ $num.='['.$lda[-1].'-'.$uda[-1].']';
}
}
}
@@ -208,7 +205,6 @@ sub initsheet {
$safeeval->deny(":base_io");
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
$safehole->wrap(\&Apache::lonspreadsheet::mask,$safeeval,'&mask');
- $safehole->wrap(\&Apache::lonspreadsheet::templaterow,$safeeval,'&templaterow');
$safeeval->share('$@');
my $code=<<'ENDDEFS';
# ---------------------------------------------------- Inside of the safe space
@@ -238,8 +234,6 @@ undef %c; # Holds the constants for a sh
# sheets, this is the A column. Used in &MINPARM, &MAXPARM, &expandnamed,
# &sett, and &setconstants. There is no &getconstants.
# &setconstants is called by &loadstudent, &loadcourse, &load assessment,
-undef %rowlabel; # Holds the 'prefix' for each row. Set by &setrowlabels.
- # &setrowlabels is called by &updateclasssheet, &updatestudentassesssheet,
undef @os; # Holds the names of other spreadsheets - this is used to specify
# the spreadsheets that are available for the assessment sheet.
# Set by &setothersheets. &setothersheets is called by &handler. A
@@ -945,19 +939,42 @@ sub calc {
return '';
}
+# ------------------------------------------- End of "Inside of the safe space"
+ENDDEFS
+ $safeeval->reval($code);
+ return $safeeval;
+}
+
#
# This is actually used for the student spreadsheet, not the assessment sheet
# Do not be fooled by the name!
#
+sub templaterow {
+ my $sheet = shift;
+ my @cols=();
+ $cols[0]='Template';
+ foreach ('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',
+ '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,"'template_$_','$fm'".'___eq___'.$fm);
+ }
+ return @cols;
+}
+
+
sub outrowassess {
# $n is the current row number
+ my $sheet = shift;
my $n=shift;
- my $csv = shift;
+ my $csv = $ENV{'form.showcsv'};
my @cols=();
if ($n) {
- my ($usy,$ufn)=split(/__&&&\__/,$f{'A'.$n});
- if ($rowlabel{$usy}) {
- $cols[0]=$rowlabel{$usy};
+ my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n});
+ if ($sheet->{'rowlabel'}->{$usy}) {
+ $cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$usy});
if (! $csv) {
$cols[0].=' '.
'