version 1.140, 2002/11/15 18:19:10
|
version 1.142, 2002/11/19 19:20:50
|
Line 1186 sub get_row {
|
Line 1186 sub get_row {
|
######################################################################## |
######################################################################## |
sub sort_indicies { |
sub sort_indicies { |
my $sheet = shift; |
my $sheet = shift; |
# |
|
# Sort the rows in some manner |
|
# |
|
my @sortby=(); |
|
my @sortidx=(); |
my @sortidx=(); |
# Skip row 0 |
# |
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) { |
if ($sheet->{'sheettype'} eq 'classcalc') { |
push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}')); |
my @sortby=(); |
push (@sortidx, $row); |
# Skip row 0 |
|
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) { |
|
my (undef,$sname,$sdom,$fullname,$section,$id) = |
|
split(':',$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$row}}); |
|
push (@sortby, lc($fullname)); |
|
push (@sortidx, $row); |
|
} |
|
@sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx; |
|
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
|
my @sortby=(); |
|
# Skip row 0 |
|
&Apache::lonnet::logthis('starting sort for studentcalc'); |
|
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) { |
|
my (undef,$symb,$uname,$udom,$mapid,$resid,$title) = |
|
split(':',$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$row}}); |
|
$symb = &Apache::lonnet::unescape($symb); |
|
my ($sequence) = ($symb =~ /\/([^\/]*\.sequence)/); |
|
if ($sequence eq '') { |
|
$sequence = $symb; |
|
} |
|
push (@sortby, $sequence); |
|
push (@sortidx, $row); |
|
} |
|
@sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx; |
|
} else { |
|
my @sortby=(); |
|
# Skip row 0 |
|
for (my $row=1;$row<=$sheet->{'maxrow'};$row++) { |
|
push (@sortby, $sheet->{'safe'}->reval('$f{"A'.$row.'"}')); |
|
push (@sortidx, $row); |
|
} |
|
@sortidx = sort { $sortby[$a] cmp $sortby[$b]; } @sortidx; |
} |
} |
@sortidx=sort { lc($sortby[$a]) cmp lc($sortby[$b]); } @sortidx; |
|
return @sortidx; |
return @sortidx; |
} |
} |
|
|
Line 1332 END
|
Line 1358 END
|
foreach my $rownum (@Rows) { |
foreach my $rownum (@Rows) { |
my ($rowlabel,@rowdata) = &get_row($sheet,$rownum); |
my ($rowlabel,@rowdata) = &get_row($sheet,$rownum); |
next if ($rowlabel =~ /^\s*$/); |
next if ($rowlabel =~ /^\s*$/); |
|
next if (($sheet->{'sheettype'} eq 'assesscalc') && |
|
(! $ENV{'form.showall'}) && |
|
($rowdata[0]->{'value'} =~ /^\s*$/)); |
|
if ($sheet->{'sheettype'} =~ /^(studentcalc|classcalc)$/) { |
|
my $row_is_empty = 1; |
|
foreach my $cell (@rowdata) { |
|
if ($cell->{'value'} !~ /^\s*$/) { |
|
$row_is_empty = 0; |
|
last; |
|
} |
|
} |
|
next if $row_is_empty; |
|
} |
# |
# |
my $defaultbg='#E0FF'; |
my $defaultbg='#E0FF'; |
# |
# |
Line 1753 sub readsheet {
|
Line 1792 sub readsheet {
|
if ($fh=Apache::File->new($includedir.'/'.$dfn)) { |
if ($fh=Apache::File->new($includedir.'/'.$dfn)) { |
$sheetxml=join('',<$fh>); |
$sheetxml=join('',<$fh>); |
} else { |
} else { |
$sheetxml='<field row="0" col="A">"Error"</field>'; |
# $sheetxml='<field row="0" col="A">"Error"</field>'; |
|
$sheetxml='<field row="0" col="A"></field>'; |
} |
} |
%f=%{&parse_sheet(\$sheetxml)}; |
%f=%{&parse_sheet(\$sheetxml)}; |
} elsif($fn=~/\/*\.spreadsheet$/) { |
} elsif($fn=~/\/*\.spreadsheet$/) { |
Line 3115 ENDSCRIPT
|
Line 3155 ENDSCRIPT
|
# Write the modified worksheet |
# Write the modified worksheet |
$r->print('<b>Current sheet:</b> '.$sheet->{'filename'}.'</p>'); |
$r->print('<b>Current sheet:</b> '.$sheet->{'filename'}.'</p>'); |
&tmpwrite($sheet); |
&tmpwrite($sheet); |
if ($sheet->{'sheettype'} eq 'studentcalc') { |
if ($sheet->{'sheettype'} eq 'assesscalc') { |
$r->print('<p>Show rows with empty A column: '); |
$r->print('<p>Show rows with empty A column: '); |
} else { |
} else { |
$r->print('<p>Show empty rows: '); |
$r->print('<p>Show empty rows: '); |