version 1.59, 2001/09/01 20:38:52
|
version 1.67, 2001/10/16 19:27:19
|
Line 6
|
Line 6
|
# 01/01/01,02/01,03/01,19/01,20/01,22/01, |
# 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/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, |
# 03/19,03/20,03/21,03/27,04/05,04/09, |
# 07/09,07/14,07/21,09/01 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; |
package Apache::lonspreadsheet; |
|
|
Line 670 sub rown {
|
Line 670 sub rown {
|
my ($safeeval,$n)=@_; |
my ($safeeval,$n)=@_; |
my $defaultbg; |
my $defaultbg; |
my $rowdata=''; |
my $rowdata=''; |
|
my $dataflag=0; |
unless ($n eq '-') { |
unless ($n eq '-') { |
$defaultbg=((($n-1)/5)==int(($n-1)/5))?'#E0E0':'#FFFF'; |
$defaultbg=((($n-1)/5)==int(($n-1)/5))?'#E0E0':'#FFFF'; |
} else { |
} else { |
$defaultbg='#E0FF'; |
$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.="</table>\n<br><table border=2>". |
|
'<tr><td> <td>'.$what.'</td>'; |
|
map { |
|
$rowdata.='<td>'.$_.'</td>'; |
|
} ('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.='</tr>'; |
|
} |
|
$rowdata.="\n<tr><td><b><font size=+1>$n</font></b></td>"; |
$rowdata.="\n<tr><td><b><font size=+1>$n</font></b></td>"; |
my $showf=0; |
my $showf=0; |
my $proc; |
my $proc; |
my $maxred; |
my $maxred; |
if (&gettype($safeeval) eq 'studentcalc') { |
my $sheettype=&gettype($safeeval); |
|
if ($sheettype eq 'studentcalc') { |
$proc='&outrowassess'; |
$proc='&outrowassess'; |
$maxred=26; |
$maxred=26; |
} else { |
} else { |
$proc='&outrow'; |
$proc='&outrow'; |
} |
} |
if (&gettype($safeeval) eq 'assesscalc') { |
if ($sheettype eq 'assesscalc') { |
$maxred=1; |
$maxred=1; |
} else { |
} else { |
$maxred=26; |
$maxred=26; |
} |
} |
if ($n eq '-') { $proc='&templaterow'; $n=-1; } |
if ($n eq '-') { $proc='&templaterow'; $n=-1; $dataflag=1; } |
map { |
map { |
my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD'); |
my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD'); |
my ($fm,$vl)=split(/\_\_\_eq\_\_\_/,$_); |
my ($fm,$vl)=split(/\_\_\_eq\_\_\_/,$_); |
|
if ((($vl ne '') || ($vl eq '0')) && |
|
(($showf==1) || ($sheettype ne 'studentcalc'))) { $dataflag=1; } |
if ($showf==0) { $vl=$_; } |
if ($showf==0) { $vl=$_; } |
if ($showf<=$maxred) { $bgcolor='#FFDDDD'; } |
if ($showf<=$maxred) { $bgcolor='#FFDDDD'; } |
if (($n==0) && ($showf<=26)) { $bgcolor='#CCCCFF'; } |
if (($n==0) && ($showf<=26)) { $bgcolor='#CCCCFF'; } |
Line 726 sub rown {
|
Line 713 sub rown {
|
} |
} |
$showf++; |
$showf++; |
} $safeeval->reval($proc.'('.$n.')'); |
} $safeeval->reval($proc.'('.$n.')'); |
return $rowdata.'</tr>'; |
if ($ENV{'form.showall'} || ($dataflag)) { |
|
return $rowdata.'</tr>'; |
|
} else { |
|
return ''; |
|
} |
} |
} |
|
|
# ------------------------------------------------------------- Print out sheet |
# ------------------------------------------------------------- Print out sheet |
Line 769 sub outsheet {
|
Line 760 sub outsheet {
|
$tabledata.='</tr>'; |
$tabledata.='</tr>'; |
my $row; |
my $row; |
my $maxrow=&getmaxrow($safeeval); |
my $maxrow=&getmaxrow($safeeval); |
$tabledata.=&rown($safeeval,'-'); |
$tabledata.=&rown($safeeval,'-').&rown($safeeval,0); |
$r->print($tabledata); |
$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("</table>\n<br>\n"); |
|
$r->rflush(); |
|
$r->print('<table border=2><tr><td> <td>'.$what.'</td>'); |
|
map { |
|
$r->print('<td>'.$_.'</td>'); |
|
} ('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('</tr>'); |
|
} |
|
$n++; |
|
$r->print($thisrow); |
|
} |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
} |
} |
Line 1513 sub loadassessment {
|
Line 1537 sub loadassessment {
|
# ----------------- now courseopt, useropt initialized for this user and course |
# ----------------- now courseopt, useropt initialized for this user and course |
# (used by parmval) |
# (used by parmval) |
|
|
|
# |
|
# Load keys for this assessment only |
|
# |
|
my %thisassess=(); |
|
my ($symap,$syid,$srcf)=split(/\_\_\_/,$symb); |
|
|
|
map { |
|
$thisassess{$_}=1; |
|
} split(/\,/,&Apache::lonnet::metadata($srcf,'keys')); |
|
# |
|
# Load parameters |
|
# |
my %c=(); |
my %c=(); |
|
|
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
Line 1522 sub loadassessment {
|
Line 1558 sub loadassessment {
|
if ($_=~/^A/) { |
if ($_=~/^A/) { |
unless ($f{$_}=~/^\!/) { |
unless ($f{$_}=~/^\!/) { |
if ($f{$_}=~/^parameter/) { |
if ($f{$_}=~/^parameter/) { |
|
if ($thisassess{$f{$_}}) { |
my $val=&parmval($f{$_},$safeeval); |
my $val=&parmval($f{$_},$safeeval); |
$c{$_}=$val; |
$c{$_}=$val; |
$c{$f{$_}}=$val; |
$c{$f{$_}}=$val; |
|
} |
} else { |
} else { |
my $key=$f{$_}; |
my $key=$f{$_}; |
my $ckey=$key; |
my $ckey=$key; |
Line 1973 ENDSCRIPT
|
Line 2011 ENDSCRIPT
|
# ---------------------------------------------------------------- Course title |
# ---------------------------------------------------------------- Course title |
|
|
$r->print('<h1>'. |
$r->print('<h1>'. |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1>'); |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
|
'</h1><h3>'.localtime().'</h3>'); |
|
|
# ---------------------------------------------------- See if user can see this |
# ---------------------------------------------------- See if user can see this |
|
|
Line 2096 ENDSCRIPT
|
Line 2135 ENDSCRIPT
|
|
|
&tmpwrite($asheet); |
&tmpwrite($asheet); |
|
|
|
if (&gettype($asheet) eq 'studentcalc') { |
|
$r->print('<br>Show rows with empty A column: '); |
|
} else { |
|
$r->print('<br>Show empty rows: '); |
|
} |
|
$r->print('<input type=checkbox name=showall onClick="submit()"'); |
|
if ($ENV{'form.showall'}) { $r->print(' checked'); } |
|
$r->print('>'); |
|
|
# ------------------------------------------------------------- Print out sheet |
# ------------------------------------------------------------- Print out sheet |
|
|
&outsheet($r,$asheet); |
&outsheet($r,$asheet); |