version 1.131, 2002/10/30 15:07:20
|
version 1.132, 2002/11/04 22:35:45
|
Line 122 my $tmpdir;
|
Line 122 my $tmpdir;
|
## |
## |
sub mask { |
sub mask { |
my ($lower,$upper)=@_; |
my ($lower,$upper)=@_; |
|
$upper = $lower if (! defined($upper)); |
# |
# |
my ($la,$ld) = ($lower=~/([A-Za-z]|\*)(\d+|\*)/); |
my ($la,$ld) = ($lower=~/([A-Za-z]|\*)(\d+|\*)/); |
my ($ua,$ud) = ($upper=~/([A-Za-z]|\*)(\d+|\*)/); |
my ($ua,$ud) = ($upper=~/([A-Za-z]|\*)(\d+|\*)/); |
Line 130 sub mask {
|
Line 131 sub mask {
|
my $num=''; |
my $num=''; |
# |
# |
if (($la eq '*') || ($ua eq '*')) { |
if (($la eq '*') || ($ua eq '*')) { |
$alpha='[A-Za-z]'; |
$alpha='[A-Za-z]'; |
} else { |
} else { |
|
|
if (($la=~/[A-Z]/) && ($ua=~/[A-Z]/) || |
if (($la=~/[A-Z]/) && ($ua=~/[A-Z]/) || |
($la=~/[a-z]/) && ($ua=~/[a-z]/)) { |
($la=~/[a-z]/) && ($ua=~/[a-z]/)) { |
$alpha='['.$la.'-'.$ua.']'; |
$alpha='['.$la.'-'.$ua.']'; |
Line 194 sub mask {
|
Line 194 sub mask {
|
return '^'.$alpha.$num."\$"; |
return '^'.$alpha.$num."\$"; |
} |
} |
|
|
|
|
|
|
sub initsheet { |
sub initsheet { |
my $safeeval = new Safe(shift); |
my $safeeval = new Safe(shift); |
my $safehole = new Safe::Hole; |
my $safehole = new Safe::Hole; |
Line 238 undef @os; # Holds the names of other s
|
Line 236 undef @os; # Holds the names of other s
|
# the spreadsheets that are available for the assessment sheet. |
# the spreadsheets that are available for the assessment sheet. |
# Set by &setothersheets. &setothersheets is called by &handler. A |
# Set by &setothersheets. &setothersheets is called by &handler. A |
# related subroutine is &othersheets. |
# related subroutine is &othersheets. |
|
#$errorlog = ''; |
|
|
$maxrow = 0; |
$maxrow = 0; |
$sheettype = ''; |
$sheettype = ''; |
Line 591 compute the average of the items in the
|
Line 590 compute the average of the items in the
|
#------------------------------------------------------- |
#------------------------------------------------------- |
sub MEAN { |
sub MEAN { |
my $mask=mask(@_); |
my $mask=mask(@_); |
my $sum=0; my $num=0; |
my $sum=0; |
|
my $num=0; |
foreach (grep /$mask/,keys(%sheet_values)) { |
foreach (grep /$mask/,keys(%sheet_values)) { |
$sum+=$sheet_values{$_}; |
$sum+=$sheet_values{$_}; |
$num++; |
$num++; |
Line 926 sub calc {
|
Line 926 sub calc {
|
while ($notfinished) { |
while ($notfinished) { |
$notfinished=0; |
$notfinished=0; |
foreach (keys(%t)) { |
foreach (keys(%t)) { |
|
#$errorlog .= "$_:".$t{$_}; |
my $old=$sheet_values{$_}; |
my $old=$sheet_values{$_}; |
$sheet_values{$_}=eval $t{$_}; |
$sheet_values{$_}=eval $t{$_}; |
if ($@) { |
if ($@) { |
Line 933 sub calc {
|
Line 934 sub calc {
|
return $_.': '.$@; |
return $_.': '.$@; |
} |
} |
if ($sheet_values{$_} ne $old) { $notfinished=1; $lastcalc=$_; } |
if ($sheet_values{$_} ne $old) { $notfinished=1; $lastcalc=$_; } |
|
#$errorlog .= ":".$sheet_values{$_}."\n"; |
} |
} |
$depth++; |
$depth++; |
if ($depth>100) { |
if ($depth>100) { |
Line 950 ENDDEFS
|
Line 952 ENDDEFS
|
} |
} |
|
|
# |
# |
# |
# |
# |
# |
sub templaterow { |
sub templaterow { |
my $sheet = shift; |
my $sheet = shift; |
my @cols=(); |
my @cols=(); |
$cols[0]='<b><font size=+1>Template</font></b>'; |
my $rowlabel = 'Template'; |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
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', |
'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', |
'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') { |
'n','o','p','q','r','s','t','u','v','w','x','y','z') { |
my $fm=$sheet->{'f'}->{'template_'.$_}; |
my $fm=$sheet->{'f'}->{'template_'.$_}; |
$fm=~s/[\'\"]/\&\#34;/g; |
$fm=~s/[\'\"]/\&\#34;/g; |
push(@cols,"'template_$_','$fm'".'___eq___'.$fm); |
push(@cols,{ name => 'template_'.$_, |
|
formula => $fm, |
|
value => $fm }); |
} |
} |
return @cols; |
return ($rowlabel,@cols); |
} |
} |
|
|
|
|
sub outrowassess { |
sub outrowassess { |
# $n is the current row number |
# $n is the current row number |
my $sheet = shift; |
my ($sheet,$n) = @_; |
my $n=shift; |
|
my $csv = $ENV{'form.showcsv'}; |
|
my @cols=(); |
my @cols=(); |
|
my $rowlabel=''; |
if ($n) { |
if ($n) { |
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n}); |
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n}); |
if ($sheet->{'rowlabel'}->{$usy}) { |
if (exists($sheet->{'rowlabel'}->{$usy})) { |
$cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$usy}); |
$rowlabel = $sheet->{'rowlabel'}->{$usy}; |
if (! $csv) { |
|
$cols[0].='<br>'. |
|
'<select name="sel_'.$n.'" onChange="changesheet('.$n.')">'. |
|
'<option name="default">Default</option>'; |
|
} |
|
} else { |
} else { |
$cols[0]=''; |
$rowlabel = ''; |
} |
|
if (! $csv) { |
|
foreach (@{$sheet->{'othersheets'}}) { |
|
$cols[0].='<option name="'.$_.'"'; |
|
if ($ufn eq $_) { |
|
$cols[0].=' selected'; |
|
} |
|
$cols[0].='>'.$_.'</option>'; |
|
} |
|
$cols[0].='</select>'; |
|
} |
} |
} else { |
} else { |
$cols[0]='<b><font size=+1>Export</font></b>'; |
$rowlabel = 'Export'; |
} |
} |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
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', |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
Line 1005 sub outrowassess {
|
Line 992 sub outrowassess {
|
'n','o','p','q','r','s','t','u','v','w','x','y','z') { |
'n','o','p','q','r','s','t','u','v','w','x','y','z') { |
my $fm=$sheet->{'f'}->{$_.$n}; |
my $fm=$sheet->{'f'}->{$_.$n}; |
$fm=~s/[\'\"]/\&\#34;/g; |
$fm=~s/[\'\"]/\&\#34;/g; |
push(@cols,"'$_$n','$fm'".'___eq___'.$sheet->{'values'}->{$_.$n}); |
push(@cols,{ name => $_.$n, |
|
formula => $fm, |
|
value => $sheet->{'values'}->{$_.$n}}); |
} |
} |
return @cols; |
return ($rowlabel,@cols); |
} |
} |
|
|
sub outrow { |
sub outrow { |
my $sheet=shift; |
my ($sheet,$n)=@_; |
my $n=shift; |
|
my @cols=(); |
my @cols=(); |
|
my $rowlabel; |
if ($n) { |
if ($n) { |
$cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$n}}); |
$rowlabel = $sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$n}}; |
} else { |
} else { |
$cols[0]='<b><font size=+1>Export</font></b>'; |
if ($sheet->{'sheettype'} eq 'classcalc') { |
|
$rowlabel = 'Summary'; |
|
} else { |
|
$rowlabel = 'Export'; |
|
} |
} |
} |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
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', |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
Line 1025 sub outrow {
|
Line 1018 sub outrow {
|
'n','o','p','q','r','s','t','u','v','w','x','y','z') { |
'n','o','p','q','r','s','t','u','v','w','x','y','z') { |
my $fm=$sheet->{'f'}->{$_.$n}; |
my $fm=$sheet->{'f'}->{$_.$n}; |
$fm=~s/[\'\"]/\&\#34;/g; |
$fm=~s/[\'\"]/\&\#34;/g; |
push(@cols,"'$_$n','$fm'".'___eq___'.$sheet->{'values'}->{$_.$n}); |
push(@cols,{ name => $_.$n, |
|
formula => $fm, |
|
value => $sheet->{'values'}->{$_.$n}}); |
} |
} |
return @cols; |
return ($rowlabel,@cols); |
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
Line 1083 sub getformulas {
|
Line 1078 sub getformulas {
|
return %{$sheet->{'safe'}->varglob('f')}; |
return %{$sheet->{'safe'}->varglob('f')}; |
} |
} |
|
|
|
sub geterrorlog { |
|
my $sheet = shift; |
|
return ${$sheet->{'safe'}->varglob('errorlog')}; |
|
} |
|
|
# ----------------------------------------------------- Get value of $f{'A'.$n} |
# ----------------------------------------------------- Get value of $f{'A'.$n} |
sub getfa { |
sub getfa { |
my $sheet = shift; |
my $sheet = shift; |
Line 1113 sub exportdata {
|
Line 1113 sub exportdata {
|
# |
# |
# --------------------------------------------- Produce output row n from sheet |
# --------------------------------------------- Produce output row n from sheet |
|
|
sub rown { |
sub get_row { |
my ($sheet,$n)=@_; |
my ($sheet,$n) = @_; |
my $defaultbg; |
my ($rowlabel,@rowdata); |
my $rowdata=''; |
|
my $dataflag=0; |
|
unless ($n eq '-') { |
|
$defaultbg=((($n-1)/5)==int(($n-1)/5))?'#E0E0':'#FFFF'; |
|
} else { |
|
$defaultbg='#E0FF'; |
|
} |
|
unless ($ENV{'form.showcsv'}) { |
|
$rowdata.="\n<tr><td><b><font size=+1>$n</font></b></td>"; |
|
} else { |
|
$rowdata.="\n".'"'.$n.'"'; |
|
} |
|
my $showf=0; |
|
# |
|
# Determine how many pink (uneditable) cells there are in this sheet. |
|
my $maxred=1; |
|
my $sheettype=$sheet->{'sheettype'}; |
|
if ($sheettype eq 'studentcalc') { |
|
$maxred=26; |
|
} elsif ($sheettype eq 'assesscalc') { |
|
$maxred=1; |
|
} else { |
|
$maxred=26; |
|
} |
|
$maxred=1 if (&getfa($sheet,$n)=~/^[\~\-]/); |
|
# |
|
# Get the proper row |
|
my @rowdata; |
|
if ($n eq '-') { |
if ($n eq '-') { |
@rowdata = &templaterow($sheet); |
($rowlabel,@rowdata) = &templaterow($sheet); |
$n=-1; |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
$dataflag=1; |
($rowlabel,@rowdata) = &outrowassess($sheet,$n); |
} elsif ($sheettype eq 'studentcalc') { |
|
@rowdata = &outrowassess($sheet,$n); |
|
} else { |
|
@rowdata = &outrow($sheet,$n); |
|
} |
|
# |
|
foreach (@rowdata) { |
|
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=$_; } |
|
unless ($ENV{'form.showcsv'}) { |
|
if ($showf<=$maxred) { $bgcolor='#FFDDDD'; } |
|
if (($n==0) && ($showf<=26)) { $bgcolor='#CCCCFF'; } |
|
if (($showf>$maxred) || ((!$n) && ($showf>0))) { |
|
if ($vl eq '') { |
|
$vl='<font size=+2 color='.$bgcolor.'>#</font>'; |
|
} |
|
$rowdata.='<td bgcolor='.$bgcolor.'>'; |
|
if ($ENV{'request.role'} =~ /^st\./) { |
|
$rowdata.=$vl; |
|
} else { |
|
$rowdata.='<a href="javascript:celledit('.$fm.');">'. |
|
$vl.'</a>'; |
|
} |
|
$rowdata.='</td>'; |
|
} else { |
|
$rowdata.='<td bgcolor='.$bgcolor.'> '.$vl.' </td>'; |
|
} |
|
} else { |
|
$rowdata.=',"'.$vl.'"'; |
|
} |
|
$showf++; |
|
} # End of foreach($safeval...) |
|
if ($ENV{'form.showall'} || ($dataflag)) { |
|
return $rowdata.($ENV{'form.showcsv'}?'':'</tr>'); |
|
} else { |
} else { |
return ''; |
($rowlabel,@rowdata) = &outrow($sheet,$n); |
} |
} |
|
return ($rowlabel,@rowdata); |
} |
} |
|
|
# ------------------------------------------------------------- Print out sheet |
######################################################################## |
|
######################################################################## |
sub outsheet { |
sub sort_indicies { |
my ($r,$sheet)=@_; |
my $sheet = shift; |
my $maxred = 26; # The maximum number of cells to show as |
|
# red (uneditable) |
|
# To make student sheets uneditable could we |
|
# set $maxred = 52? |
|
# |
|
my $realm='Course'; # 'assessment', 'user', or 'course' sheet |
|
if ($sheet->{'sheettype'} eq 'assesscalc') { |
|
$maxred=1; |
|
$realm='Assessment'; |
|
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
|
$maxred=26; |
|
$realm='User'; |
|
} |
|
# |
|
# Column label |
|
my $tabledata; |
|
if ($ENV{'form.showcsv'}) { |
|
$tabledata='<pre>'; |
|
} else { |
|
$tabledata='<table border=2><tr><th colspan=2 rowspan=2>'. |
|
'<font size=+2>'.$realm.'</font></th>'. |
|
'<td bgcolor=#FFDDDD colspan='.$maxred. |
|
'><b><font size=+1>Import</font></b></td>'. |
|
'<td colspan='.(52-$maxred). |
|
'><b><font size=+1>Calculations</font></b></td></tr><tr>'; |
|
my $showf=0; |
|
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') { |
|
$showf++; |
|
if ($showf<=$maxred) { |
|
$tabledata.='<td bgcolor="#FFDDDD">'; |
|
} else { |
|
$tabledata.='<td>'; |
|
} |
|
$tabledata.="<b><font size=+1>$_</font></b></td>"; |
|
} |
|
$tabledata.='</tr>'.&rown($sheet,'-'). |
|
&rown($sheet,0); |
|
} |
|
$r->print($tabledata); |
|
# |
|
# Prepare to output rows |
|
my $row; |
|
# |
# |
# Sort the rows in some manner |
# Sort the rows in some manner |
# |
# |
my @sortby=(); |
my @sortby=(); |
my @sortidx=(); |
my @sortidx=(); |
for ($row=1;$row<=$sheet->{'maxrow'};$row++) { |
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) { |
push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}')); |
push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}')); |
push (@sortidx, $row-1); |
push (@sortidx, $row); |
} |
} |
@sortidx=sort { lc($sortby[$a]) cmp lc($sortby[$b]); } @sortidx; |
@sortidx=sort { lc($sortby[$a]) cmp lc($sortby[$b]); } @sortidx; |
|
return @sortidx; |
|
} |
|
|
|
######################################################################## |
|
######################################################################## |
|
|
|
sub html_editable_cell { |
|
my ($cell,$bgcolor) = @_; |
|
my $result; |
|
# if (defined($cell)) { |
|
# &Apache::lonnet::logthis("cell ".$cell->{'name'}. |
|
# " = ".$cell->{'value'}. |
|
# " : ".$cell->{'formula'}); |
|
# } |
|
my ($name,$formula,$value); |
|
if (defined($cell)) { |
|
$name = $cell->{'name'}; |
|
$formula = $cell->{'formula'}; |
|
$value = $cell->{'value'}; |
|
} |
|
$name = '' if (! defined($name)); |
|
$formula = '' if (! defined($formula)); |
|
if (! defined($value)) { |
|
$value = '<font color="'.$bgcolor.'">#</font>'; |
|
if ($formula ne '') { |
|
$value = '<i>undefined value</i>'; |
|
} |
|
} |
# |
# |
# Determine the type of child spreadsheets |
$result .= '<a href="javascript:celledit(\''. |
my $what='Student'; |
$name.'\',\''.$formula.'\');">'.$value.'</a>'; |
|
return $result; |
|
} |
|
|
|
sub html_uneditable_cell { |
|
my ($cell,$bgcolor) = @_; |
|
my $value = (defined($cell) ? $cell->{'value'} : ''); |
|
return ' '.$value.' '; |
|
} |
|
|
|
######################################################################## |
|
######################################################################## |
|
|
|
sub outsheet_html { |
|
my ($sheet,$r) = @_; |
|
my ($num_uneditable,$realm,$row_type); |
if ($sheet->{'sheettype'} eq 'assesscalc') { |
if ($sheet->{'sheettype'} eq 'assesscalc') { |
$what='Item'; |
$num_uneditable = 1; |
|
$realm = 'Assessment'; |
|
$row_type = 'Item'; |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
$what='Assessment'; |
$num_uneditable = 26; |
|
$realm = 'User'; |
|
$row_type = 'Assessment'; |
|
} elsif ($sheet->{'sheettype'} eq 'classcalc') { |
|
$num_uneditable = 26; |
|
$realm = 'Course'; |
|
$row_type = 'Student'; |
|
} else { |
|
return; # error |
|
} |
|
#################################### |
|
# Print out header table |
|
#################################### |
|
my $num_left = 52-$num_uneditable; |
|
my $tabledata =<<"END"; |
|
<table border="2"> |
|
<tr> |
|
<th colspan="1" rowspan="2"><font size="+2">$realm</font></th> |
|
<td bgcolor="#FFDDDD" colspan="$num_uneditable"> |
|
<b><font size="+1">Import</font></b></td> |
|
<td colspan="$num_left"> |
|
<b><font size="+1">Calculations</font></b></td> |
|
</tr><tr> |
|
END |
|
my $label_num = 0; |
|
foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){ |
|
if ($label_num<$num_uneditable) { |
|
$tabledata.='<td bgcolor="#FFDDDD">'; |
|
} else { |
|
$tabledata.='<td>'; |
|
} |
|
$tabledata.="<b><font size=+1>$_</font></b></td>"; |
|
$label_num++; |
} |
} |
|
$tabledata.="</tr>\n"; |
|
$r->print($tabledata); |
|
#################################### |
|
# Print out template row |
|
#################################### |
|
my ($rowlabel,@rowdata) = &get_row($sheet,'-'); |
|
my $row_html = '<tr><td>'.&format_rowlabel($rowlabel).'</td>'; |
|
my $num_cols_output = 0; |
|
foreach my $cell (@rowdata) { |
|
if ($num_cols_output++ < $num_uneditable) { |
|
$row_html .= '<td bgcolor="#FFDDDD">'; |
|
$row_html .= &html_uneditable_cell($cell,'#FFDDDD'); |
|
} else { |
|
$row_html .= '<td bgcolor="#EOFFDD">'; |
|
$row_html .= &html_editable_cell($cell,'#E0FFDD'); |
|
} |
|
$row_html .= '</td>'; |
|
} |
|
$row_html.= "</tr>\n"; |
|
$r->print($row_html); |
|
#################################### |
|
# Print out summary/export row |
|
#################################### |
|
my ($rowlabel,@rowdata) = &get_row($sheet,'0'); |
|
my $rowcount = 0; |
|
$row_html = '<tr><td>'.&format_rowlabel($rowlabel).'</td>'; |
|
$num_cols_output = 0; |
|
foreach my $cell (@rowdata) { |
|
if ($num_cols_output++ < 26) { |
|
$row_html .= '<td bgcolor="#CCCCFF">'; |
|
$row_html .= &html_editable_cell($cell,'#CCCCFF'); |
|
} else { |
|
$row_html .= '<td bgcolor="#DDCCFF">'; |
|
$row_html .= &html_uneditable_cell(undef,'#CCCCFF'); |
|
} |
|
$row_html .= '</td>'; |
|
} |
|
$row_html.= "</tr>\n"; |
|
$r->print($row_html); |
|
$r->print('</table>'); |
|
#################################### |
|
# Prepare to output rows |
|
#################################### |
|
my @Rows = &sort_indicies($sheet); |
# |
# |
# Loop through the rows and output them one at a time |
# Loop through the rows and output them one at a time |
my $n=0; |
my $rows_output=0; |
for ($row=0;$row<$sheet->{'maxrow'};$row++) { |
foreach my $rownum (@Rows) { |
my $thisrow=&rown($sheet,$sortidx[$row]+1); |
my ($rowlabel,@rowdata) = &get_row($sheet,$rownum); |
if ($thisrow) { |
# |
if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) { |
my $defaultbg='#E0FF'; |
|
# |
|
my $row_html ="\n".'<tr><td><b><font size=+1>'.$rownum. |
|
'</font></b></td>'; |
|
# |
|
if ($sheet->{'sheettype'} eq 'classcalc') { |
|
$row_html.='<td>'.&format_rowlabel($rowlabel).'</td>'; |
|
# Output links for each student? |
|
# Nope, that is already done for us in format_rowlabel (for now) |
|
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
|
$row_html.='<td>'.&format_rowlabel($rowlabel); |
|
$row_html.= '<br>'. |
|
'<select name="sel_'.$rownum.'" '. |
|
'onChange="changesheet('.$rownum.')">'. |
|
'<option name="default">Default</option>'; |
|
foreach (@{$sheet->{'othersheets'}}) { |
|
$row_html.='<option name="'.$_.'"'; |
|
#if ($ufn eq $_) { |
|
# $row_html.=' selected'; |
|
#} |
|
$row_html.='>'.$_.'</option>'; |
|
} |
|
$row_html.='</select></td>'; |
|
} elsif ($sheet->{'sheettype'} eq 'assesscalc') { |
|
$row_html.='<td>'.&format_rowlabel($rowlabel).'</td>'; |
|
} |
|
# |
|
my $shown_cells = 0; |
|
foreach my $cell (@rowdata) { |
|
my $value = $cell->{'value'}; |
|
my $formula = $cell->{'formula'}; |
|
my $cellname = $cell->{'name'}; |
|
# |
|
my $bgcolor; |
|
if ($shown_cells && ($shown_cells/5 == int($shown_cells/5))) { |
|
$bgcolor = $defaultbg.'99'; |
|
} else { |
|
$bgcolor = $defaultbg.'DD'; |
|
} |
|
$bgcolor='#FFDDDD' if ($shown_cells < $num_uneditable); |
|
# |
|
$row_html.='<td bgcolor='.$bgcolor.'>'; |
|
if ($shown_cells < $num_uneditable) { |
|
$row_html .= &html_uneditable_cell($cell,$bgcolor); |
|
} else { |
|
$row_html .= &html_editable_cell($cell,$bgcolor); |
|
} |
|
$row_html.='</td>'; |
|
$shown_cells++; |
|
} |
|
if ($row_html) { |
|
if ($rows_output % 25 == 0) { |
$r->print("</table>\n<br>\n"); |
$r->print("</table>\n<br>\n"); |
$r->rflush(); |
$r->rflush(); |
$r->print('<table border=2><tr><td> <td>'.$what.'</td>'); |
$r->print('<table border=2>'. |
$r->print('<td>'. |
'<tr><td> <td>'.$row_type.'</td>'. |
|
'<td>'. |
join('</td><td>', |
join('</td><td>', |
(split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. |
(split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. |
'abcdefghijklmnopqrstuvwxyz'))). |
'abcdefghijklmnopqrstuvwxyz'))). |
"</td></tr>\n"); |
"</td></tr>\n"); |
} |
} |
$n++; |
$rows_output++; |
$r->print($thisrow); |
$r->print($row_html); |
} |
} |
} |
} |
$r->print($ENV{'form.showcsv'}?'</pre>':'</table>'); |
# |
|
$r->print('</table>'); |
|
# |
|
# Debugging code (be sure to uncomment errorlog code in safe space): |
|
# |
|
# $r->print("\n<pre>"); |
|
# $r->print(&geterrorlog($sheet)); |
|
# $r->print("\n</pre>"); |
|
return 1; |
} |
} |
|
|
# |
sub outsheet_csv { |
# ----------------------------------------------- Read list of available sheets |
my ($sheet,$r) = @_; |
# |
} |
|
|
|
sub outsheet_excel { |
|
my ($sheet,$r) = @_; |
|
} |
|
|
|
sub outsheet_xml { |
|
my ($sheet,$r) = @_; |
|
} |
|
|
|
sub outsheet { |
|
my ($r,$sheet)=@_; |
|
&outsheet_html($sheet,$r); |
|
# if (exists($ENV{'form.csv'})) { |
|
# &outsheet_csv($sheet,$r); |
|
# } elsif (exists($ENV{'form.excel'})) { |
|
# &outsheet_excel($sheet,$r); |
|
# } elsif (exists($ENV{'form.xml'})) { |
|
# &outsheet_xml($sheet,$r); |
|
# } else { |
|
# &outsheet_html($sheet,$r); |
|
# } |
|
} |
|
|
|
######################################################################## |
|
######################################################################## |
sub othersheets { |
sub othersheets { |
my ($sheet,$stype)=@_; |
my ($sheet,$stype)=@_; |
$stype = $sheet->{'sheettype'} if (! defined($stype)); |
$stype = $sheet->{'sheettype'} if (! defined($stype)); |
Line 1300 sub othersheets {
|
Line 1397 sub othersheets {
|
return @alternatives; |
return @alternatives; |
} |
} |
|
|
|
|
# |
# |
# -------------------------------------- Parse a spreadsheet |
# -------------------------------------- Parse a spreadsheet |
# |
# |
Line 1616 sub parmval {
|
Line 1712 sub parmval {
|
|
|
sub format_rowlabel { |
sub format_rowlabel { |
my $rowlabel = shift; |
my $rowlabel = shift; |
|
return '' if ($rowlabel eq ''); |
my ($type,$labeldata) = split(':',$rowlabel,2); |
my ($type,$labeldata) = split(':',$rowlabel,2); |
my $result = ''; |
my $result = ''; |
if ($type eq 'symb') { |
if ($type eq 'symb') { |
Line 1643 sub format_rowlabel {
|
Line 1740 sub format_rowlabel {
|
} |
} |
$result = $labeldata; |
$result = $labeldata; |
} else { |
} else { |
&Apache::lonnet::logthis("lonspreadsheet:bogus rowlabel type: $type"); |
if ($ENV{'form.showcsv'}) { |
|
$result = $rowlabel; |
|
} else { |
|
$result = '<b><font size=+1>'.$rowlabel.'</font></b>'; |
|
} |
} |
} |
return $result; |
return $result; |
} |
} |
Line 1932 ENDPOP
|
Line 2033 ENDPOP
|
my $index=0; |
my $index=0; |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
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') { |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') { |
if (defined($studentdata[$index++])) { |
if (defined($studentdata[$index])) { |
my $col=$_; |
my $col=$_; |
if ($studentdata[$index]=~/\D/) { |
if ($studentdata[$index]=~/\D/) { |
$c{$col.$row}="'".$studentdata[$index]."'"; |
$c{$col.$row}="'".$studentdata[$index]."'"; |
Line 1942 ENDPOP
|
Line 2043 ENDPOP
|
unless ($col eq 'A') { |
unless ($col eq 'A') { |
$f{$col.$row}='import'; |
$f{$col.$row}='import'; |
} |
} |
} |
} |
|
$index++; |
} |
} |
} |
} |
$sheet->{'f'}=\%f; |
$sheet->{'f'}=\%f; |
Line 2172 sub exportsheet {
|
Line 2274 sub exportsheet {
|
$udom = $udom || $sheet->{'udom'}; |
$udom = $udom || $sheet->{'udom'}; |
$stype = $stype || $sheet->{'sheettype'}; |
$stype = $stype || $sheet->{'sheettype'}; |
my @exportarr=(); |
my @exportarr=(); |
if (defined($usymb) && ($usymb=~/^\_(\w+)/) && (!$fn)) { |
if (defined($usymb) && ($usymb=~/^\_(\w+)/) && |
|
(!defined($fn) || $fn eq '')) { |
$fn='default_'.$1; |
$fn='default_'.$1; |
} |
} |
# |
# |