--- loncom/interface/Attic/lonspreadsheet.pm 2002/10/22 13:29:57 1.122
+++ loncom/interface/Attic/lonspreadsheet.pm 2002/10/29 16:04:13 1.130
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.122 2002/10/22 13:29:57 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.130 2002/10/29 16:04:13 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].']';
}
}
}
@@ -237,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
@@ -833,9 +828,11 @@ sub expandnamed {
foreach $parameter (keys(%c)) {
push @matches,$parameter if ($parameter =~ /$expression/);
}
- if ($#matches == 0) {
+ if (scalar(@matches) == 0) {
+ $returnvalue = 'unmatched parameter: '.$parameter;
+ } elsif (scalar(@matches) == 1) {
$returnvalue = '$c{\''.$matches[0].'\'}';
- } elsif ($#matches > 0) {
+ } elsif (scalar(@matches) > 0) {
# more than one match. Look for a concise one
$returnvalue = "'non-unique parameter name : $expression'";
foreach (@matches) {
@@ -844,7 +841,9 @@ sub expandnamed {
}
}
} else {
- $returnvalue = "'bad parameter name : $expression'";
+ # There was a negative number of matches, which indicates
+ # something is wrong with reality. Better warn the user.
+ $returnvalue = 'bizzare parameter: '.$parameter;
}
return $returnvalue;
}
@@ -951,8 +950,7 @@ ENDDEFS
}
#
-# This is actually used for the student spreadsheet, not the assessment sheet
-# Do not be fooled by the name!
+#
#
sub templaterow {
my $sheet = shift;
@@ -979,7 +977,7 @@ sub outrowassess {
if ($n) {
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n});
if ($sheet->{'rowlabel'}->{$usy}) {
- $cols[0]=$sheet->{'rowlabel'}->{$usy};
+ $cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$usy});
if (! $csv) {
$cols[0].=' '.
'