--- loncom/interface/Attic/lonspreadsheet.pm 2001/09/13 15:55:40 1.63 +++ loncom/interface/Attic/lonspreadsheet.pm 2001/10/16 19:27:19 1.67 @@ -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,9/11,9/12,9/13 Gerd Kortemeyer +# 07/09,07/14,07/21,09/01,09/10,9/11,9/12,9/13,9/14,9/17 Gerd Kortemeyer package Apache::lonspreadsheet; @@ -760,24 +760,32 @@ sub outsheet { $tabledata.=''; my $row; my $maxrow=&getmaxrow($safeeval); - $tabledata.=&rown($safeeval,'-'); + $tabledata.=&rown($safeeval,'-').&rown($safeeval,0); $r->print($tabledata); - my @rowprt=(); - for ($row=0;$row<=$maxrow;$row++) { - $rowprt[$row]=&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; } - my $n=0; - for ($row=0;$row<=$maxrow;$row++) { - if ($rowprt[$row]) { - if ((($n-1)/25)==int(($n-1)/25)) { + @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'; } - $r->print("\n
". - ''); + + 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("
 '.$what.'
\n
\n"); + $r->rflush(); + $r->print(''); map { $r->print(''); } ('A','B','C','D','E','F','G','H','I','J','K','L','M', @@ -786,12 +794,11 @@ sub outsheet { 'n','o','p','q','r','s','t','u','v','w','x','y','z'); $r->print(''); } - $n++; - $r->print($rowprt[$row]); + $n++; + $r->print($thisrow); } } $r->print('
 '.$what.''.$_.'
'); - undef @rowprt; } #