version 1.132, 2002/11/04 22:35:45
|
version 1.133, 2002/11/05 15:00:27
|
Line 1149 sub sort_indicies {
|
Line 1149 sub sort_indicies {
|
sub html_editable_cell { |
sub html_editable_cell { |
my ($cell,$bgcolor) = @_; |
my ($cell,$bgcolor) = @_; |
my $result; |
my $result; |
# if (defined($cell)) { |
|
# &Apache::lonnet::logthis("cell ".$cell->{'name'}. |
|
# " = ".$cell->{'value'}. |
|
# " : ".$cell->{'formula'}); |
|
# } |
|
my ($name,$formula,$value); |
my ($name,$formula,$value); |
if (defined($cell)) { |
if (defined($cell)) { |
$name = $cell->{'name'}; |
$name = $cell->{'name'}; |
Line 1168 sub html_editable_cell {
|
Line 1163 sub html_editable_cell {
|
$value = '<i>undefined value</i>'; |
$value = '<i>undefined value</i>'; |
} |
} |
} |
} |
# |
if ($value =~ /^\s*$/ ) { |
|
$value = '<font color="'.$bgcolor.'">#</font>'; |
|
} |
$result .= '<a href="javascript:celledit(\''. |
$result .= '<a href="javascript:celledit(\''. |
$name.'\',\''.$formula.'\');">'.$value.'</a>'; |
$name.'\',\''.$formula.'\');">'.$value.'</a>'; |
return $result; |
return $result; |
Line 1231 END
|
Line 1228 END
|
# Print out template row |
# Print out template row |
#################################### |
#################################### |
my ($rowlabel,@rowdata) = &get_row($sheet,'-'); |
my ($rowlabel,@rowdata) = &get_row($sheet,'-'); |
my $row_html = '<tr><td>'.&format_rowlabel($rowlabel).'</td>'; |
my $row_html = '<tr><td>'.&format_html_rowlabel($rowlabel).'</td>'; |
my $num_cols_output = 0; |
my $num_cols_output = 0; |
foreach my $cell (@rowdata) { |
foreach my $cell (@rowdata) { |
if ($num_cols_output++ < $num_uneditable) { |
if ($num_cols_output++ < $num_uneditable) { |
Line 1250 END
|
Line 1247 END
|
#################################### |
#################################### |
my ($rowlabel,@rowdata) = &get_row($sheet,'0'); |
my ($rowlabel,@rowdata) = &get_row($sheet,'0'); |
my $rowcount = 0; |
my $rowcount = 0; |
$row_html = '<tr><td>'.&format_rowlabel($rowlabel).'</td>'; |
$row_html = '<tr><td>'.&format_html_rowlabel($rowlabel).'</td>'; |
$num_cols_output = 0; |
$num_cols_output = 0; |
foreach my $cell (@rowdata) { |
foreach my $cell (@rowdata) { |
if ($num_cols_output++ < 26) { |
if ($num_cols_output++ < 26) { |
Line 1281 END
|
Line 1278 END
|
'</font></b></td>'; |
'</font></b></td>'; |
# |
# |
if ($sheet->{'sheettype'} eq 'classcalc') { |
if ($sheet->{'sheettype'} eq 'classcalc') { |
$row_html.='<td>'.&format_rowlabel($rowlabel).'</td>'; |
$row_html.='<td>'.&format_html_rowlabel($rowlabel).'</td>'; |
# Output links for each student? |
# Output links for each student? |
# Nope, that is already done for us in format_rowlabel (for now) |
# Nope, that is already done for us in format_html_rowlabel (for now) |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
$row_html.='<td>'.&format_rowlabel($rowlabel); |
$row_html.='<td>'.&format_html_rowlabel($rowlabel); |
$row_html.= '<br>'. |
$row_html.= '<br>'. |
'<select name="sel_'.$rownum.'" '. |
'<select name="sel_'.$rownum.'" '. |
'onChange="changesheet('.$rownum.')">'. |
'onChange="changesheet('.$rownum.')">'. |
Line 1299 END
|
Line 1296 END
|
} |
} |
$row_html.='</select></td>'; |
$row_html.='</select></td>'; |
} elsif ($sheet->{'sheettype'} eq 'assesscalc') { |
} elsif ($sheet->{'sheettype'} eq 'assesscalc') { |
$row_html.='<td>'.&format_rowlabel($rowlabel).'</td>'; |
$row_html.='<td>'.&format_html_rowlabel($rowlabel).'</td>'; |
} |
} |
# |
# |
my $shown_cells = 0; |
my $shown_cells = 0; |
Line 1354 END
|
Line 1351 END
|
|
|
sub outsheet_csv { |
sub outsheet_csv { |
my ($sheet,$r) = @_; |
my ($sheet,$r) = @_; |
|
my $csvdata = ''; |
|
my @Values; |
|
#################################### |
|
# Prepare to output rows |
|
#################################### |
|
my @Rows = &sort_indicies($sheet); |
|
# |
|
# Loop through the rows and output them one at a time |
|
my $rows_output=0; |
|
foreach my $rownum (@Rows) { |
|
my ($rowlabel,@rowdata) = &get_row($sheet,$rownum); |
|
push (@Values,&format_csv_rowlabel($rowlabel)); |
|
foreach my $cell (@rowdata) { |
|
push (@Values,'"'.$cell->{'value'}.'"'); |
|
} |
|
$csvdata.= join(',',@Values)."\n"; |
|
@Values = (); |
|
} |
|
# |
|
$r->print('<pre>'.$csvdata."\n</pre>"); |
|
# |
|
return 1; |
} |
} |
|
|
sub outsheet_excel { |
sub outsheet_excel { |
Line 1366 sub outsheet_xml {
|
Line 1385 sub outsheet_xml {
|
|
|
sub outsheet { |
sub outsheet { |
my ($r,$sheet)=@_; |
my ($r,$sheet)=@_; |
&outsheet_html($sheet,$r); |
if (exists($ENV{'form.showcsv'})) { |
# if (exists($ENV{'form.csv'})) { |
&outsheet_csv($sheet,$r); |
# &outsheet_csv($sheet,$r); |
|
# } elsif (exists($ENV{'form.excel'})) { |
# } elsif (exists($ENV{'form.excel'})) { |
# &outsheet_excel($sheet,$r); |
# &outsheet_excel($sheet,$r); |
# } elsif (exists($ENV{'form.xml'})) { |
# } elsif (exists($ENV{'form.xml'})) { |
# &outsheet_xml($sheet,$r); |
# &outsheet_xml($sheet,$r); |
# } else { |
} else { |
# &outsheet_html($sheet,$r); |
&outsheet_html($sheet,$r); |
# } |
} |
} |
} |
|
|
######################################################################## |
######################################################################## |
Line 1710 sub parmval {
|
Line 1728 sub parmval {
|
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
} |
} |
|
|
sub format_rowlabel { |
|
|
################################################################## |
|
## Row label formatting routines ## |
|
################################################################## |
|
sub format_html_rowlabel { |
my $rowlabel = shift; |
my $rowlabel = shift; |
return '' if ($rowlabel eq ''); |
return '' if ($rowlabel eq ''); |
my ($type,$labeldata) = split(':',$rowlabel,2); |
my ($type,$labeldata) = split(':',$rowlabel,2); |
Line 1718 sub format_rowlabel {
|
Line 1740 sub format_rowlabel {
|
if ($type eq 'symb') { |
if ($type eq 'symb') { |
my ($symb,$uname,$udom,$title) = split(':',$labeldata); |
my ($symb,$uname,$udom,$title) = split(':',$labeldata); |
$symb = &Apache::lonnet::unescape($symb); |
$symb = &Apache::lonnet::unescape($symb); |
if ($ENV{'form.showcsv'}) { |
$result = '<a href="/adm/assesscalc?usymb='.$symb. |
$result = $title; |
'&uname='.$uname.'&udom='.$udom.'">'.$title.'</a>'; |
} else { |
} elsif ($type eq 'student') { |
$result = '<a href="/adm/assesscalc?usymb='.$symb. |
my ($sname,$sdom,$fullname,$section,$id) = split(':',$labeldata); |
'&uname='.$uname.'&udom='.$udom.'">'.$title.'</a>'; |
$result ='<a href="/adm/studentcalc?uname='.$sname. |
} |
'&udom='.$sdom.'">'; |
|
$result.=$section.' '.$id." ".$fullname.'</a>'; |
|
} elsif ($type eq 'parameter') { |
|
$result = $labeldata; |
|
} else { |
|
$result = '<b><font size=+1>'.$rowlabel.'</font></b>'; |
|
} |
|
return $result; |
|
} |
|
|
|
sub format_csv_rowlabel { |
|
my $rowlabel = shift; |
|
return '' if ($rowlabel eq ''); |
|
my ($type,$labeldata) = split(':',$rowlabel,2); |
|
my $result = ''; |
|
if ($type eq 'symb') { |
|
my ($symb,$uname,$udom,$title) = split(':',$labeldata); |
|
$symb = &Apache::lonnet::unescape($symb); |
|
$result = $title; |
|
} elsif ($type eq 'student') { |
|
my ($sname,$sdom,$fullname,$section,$id) = split(':',$labeldata); |
|
$result = join('","',($sname,$sdom,$fullname,$section,$id)); |
|
} elsif ($type eq 'parameter') { |
|
$labeldata =~ s/<br>/ /g; |
|
$result = $labeldata; |
|
} else { |
|
$result = $rowlabel; |
|
} |
|
return '"'.$result.'"'; |
|
} |
|
|
|
sub format_plain_rowlabel { |
|
my $rowlabel = shift; |
|
return '' if ($rowlabel eq ''); |
|
my ($type,$labeldata) = split(':',$rowlabel,2); |
|
my $result = ''; |
|
if ($type eq 'symb') { |
|
my ($symb,$uname,$udom,$title) = split(':',$labeldata); |
|
$symb = &Apache::lonnet::unescape($symb); |
|
$result = $title; |
} elsif ($type eq 'student') { |
} elsif ($type eq 'student') { |
my ($sname,$sdom,$fullname,$section,$id) = split(':',$labeldata); |
my ($sname,$sdom,$fullname,$section,$id) = split(':',$labeldata); |
if ($ENV{'form.showcsv'}) { |
|
$result = '"'. |
$result = '"'. |
join('","',($sname,$sdom,$fullname,$section,$id).'"'); |
join('","',($sname,$sdom,$fullname,$section,$id).'"'); |
} else { |
|
$result ='<a href="/adm/studentcalc?uname='.$sname. |
|
'&udom='.$sdom.'">'; |
|
$result.=$section.' '.$id." ".$fullname.'</a>'; |
|
} |
|
} elsif ($type eq 'parameter') { |
} elsif ($type eq 'parameter') { |
if ($ENV{'form.showcsv'}) { |
$labeldata =~ s/<br>/ /g; |
$labeldata =~ s/<br>/ /g; |
|
} |
|
$result = $labeldata; |
$result = $labeldata; |
} else { |
} else { |
if ($ENV{'form.showcsv'}) { |
$result = $rowlabel; |
$result = $rowlabel; |
|
} else { |
|
$result = '<b><font size=+1>'.$rowlabel.'</font></b>'; |
|
} |
|
} |
} |
return $result; |
return $result; |
} |
} |