--- loncom/interface/Attic/lonspreadsheet.pm 2001/09/11 00:05:13 1.60
+++ loncom/interface/Attic/lonspreadsheet.pm 2001/10/16 09:53:50 1.66
@@ -6,7 +6,7 @@
# 01/01/01,02/01,03/01,19/01,20/01,22/01,
# 03/05,03/08,03/10,03/12,03/13,03/15,03/17,
# 03/19,03/20,03/21,03/27,04/05,04/09,
-# 07/09,07/14,07/21,09/01,09/10 Gerd Kortemeyer
+# 07/09,07/14,07/21,09/01,09/10,9/11,9/12,9/13,9/14,9/17,10/16 Gerd Kortemeyer
package Apache::lonspreadsheet;
@@ -670,47 +670,34 @@ sub rown {
my ($safeeval,$n)=@_;
my $defaultbg;
my $rowdata='';
+ my $dataflag=0;
unless ($n eq '-') {
$defaultbg=((($n-1)/5)==int(($n-1)/5))?'#E0E0':'#FFFF';
} else {
$defaultbg='#E0FF';
}
- if ((($n-1)/25)==int(($n-1)/25)) {
- my $what='Student';
- if (&gettype($safeeval) eq 'assesscalc') {
- $what='Item';
- } elsif (&gettype($safeeval) eq 'studentcalc') {
- $what='Assessment';
- }
- $rowdata.="\n
".
- ' '.$what.' ';
- map {
- $rowdata.=''.$_.' ';
- } ('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');
- $rowdata.=' ';
- }
$rowdata.="\n$n ";
my $showf=0;
my $proc;
my $maxred;
- if (&gettype($safeeval) eq 'studentcalc') {
+ my $sheettype=&gettype($safeeval);
+ if ($sheettype eq 'studentcalc') {
$proc='&outrowassess';
$maxred=26;
} else {
$proc='&outrow';
}
- if (&gettype($safeeval) eq 'assesscalc') {
+ if ($sheettype eq 'assesscalc') {
$maxred=1;
} else {
$maxred=26;
}
- if ($n eq '-') { $proc='&templaterow'; $n=-1; }
+ if ($n eq '-') { $proc='&templaterow'; $n=-1; $dataflag=1; }
map {
my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD');
my ($fm,$vl)=split(/\_\_\_eq\_\_\_/,$_);
+ if ((($vl ne '') || ($vl eq '0')) &&
+ (($showf==1) || ($sheettype ne 'studentcalc'))) { $dataflag=1; }
if ($showf==0) { $vl=$_; }
if ($showf<=$maxred) { $bgcolor='#FFDDDD'; }
if (($n==0) && ($showf<=26)) { $bgcolor='#CCCCFF'; }
@@ -726,7 +713,11 @@ sub rown {
}
$showf++;
} $safeeval->reval($proc.'('.$n.')');
- return $rowdata.' ';
+ if ($ENV{'form.showall'} || ($dataflag)) {
+ return $rowdata.'';
+ } else {
+ return '';
+ }
}
# ------------------------------------------------------------- Print out sheet
@@ -769,10 +760,43 @@ sub outsheet {
$tabledata.='';
my $row;
my $maxrow=&getmaxrow($safeeval);
- $tabledata.=&rown($safeeval,'-');
+ $tabledata.=&rown($safeeval,'-').&rown($safeeval,0);
$r->print($tabledata);
- for ($row=0;$row<=$maxrow;$row++) {
- $r->print(&rown($safeeval,$row));
+
+ my @sortby=();
+ my @sortidx=();
+ for ($row=1;$row<=$maxrow;$row++) {
+ $sortby[$row-1]=$safeeval->reval('$f{"A'.$row.'"}');
+ $sortidx[$row-1]=$row-1;
+ }
+ @sortidx=sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;
+
+ my $what='Student';
+ if (&gettype($safeeval) eq 'assesscalc') {
+ $what='Item';
+ } elsif (&gettype($safeeval) eq 'studentcalc') {
+ $what='Assessment';
+ }
+
+ my $n=0;
+ for ($row=0;$row<$maxrow;$row++) {
+ my $thisrow=&rown($safeeval,$sortidx[$row]+1);
+ if ($thisrow) {
+ if ($n/25==int($n/25)) {
+ $r->print("
\n \n");
+ $r->rflush();
+ $r->print(' '.$what.' ');
+ map {
+ $r->print(''.$_.' ');
+ } ('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');
+ $r->print(' ');
+ }
+ $n++;
+ $r->print($thisrow);
+ }
}
$r->print('
');
}
@@ -1223,6 +1247,7 @@ sub updatestudentassesssheet {
$display.=
&Apache::lonnet::metadata($srcf,$key.'.name');
}
+ $key=~s/\W/\_/g;
$display.=' '.$key;
$allkeys{$key}=$display;
}
@@ -1542,6 +1567,7 @@ sub loadassessment {
} else {
my $key=$f{$_};
my $ckey=$key;
+ $ckey=~s/\W/\_/g;
$key=~s/^stores\_/resource\./;
$key=~s/\_/\./;
$c{$_}=$returnhash{$key};
@@ -1987,7 +2013,8 @@ ENDSCRIPT
# ---------------------------------------------------------------- Course title
$r->print(''.
- $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.' ');
+ $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
+ ''.localtime().' ');
# ---------------------------------------------------- See if user can see this
@@ -2110,6 +2137,15 @@ ENDSCRIPT
&tmpwrite($asheet);
+ if (&gettype($asheet) eq 'studentcalc') {
+ $r->print(' Show rows with empty A column: ');
+ } else {
+ $r->print(' Show empty rows: ');
+ }
+ $r->print(' print(' checked'); }
+ $r->print('>');
+
# ------------------------------------------------------------- Print out sheet
&outsheet($r,$asheet);