version 1.16.2.1, 2003/12/05 22:24:20
|
version 1.17, 2003/09/05 01:06:45
|
Line 45 studentcalc
|
Line 45 studentcalc
|
################################################### |
################################################### |
package Apache::studentcalc; |
package Apache::studentcalc; |
|
|
|
use warnings FATAL=>'all'; |
|
no warnings 'uninitialized'; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
Line 98 sub initialize_sequence_cache {
|
Line 101 sub initialize_sequence_cache {
|
} |
} |
|
|
sub clear_package { |
sub clear_package { |
@Sequences = undef; |
undef(@Sequences); |
%Exportrows = undef; |
undef(%Exportrows); |
} |
} |
|
|
sub get_title { |
sub get_title { |
Line 174 sub outsheet_html {
|
Line 177 sub outsheet_html {
|
my $editing_is_allowed = &Apache::lonnet::allowed('mgr', |
my $editing_is_allowed = &Apache::lonnet::allowed('mgr', |
$ENV{'request.course.id'}); |
$ENV{'request.course.id'}); |
#################################### |
#################################### |
# Report any calculation errors # |
|
#################################### |
|
$r->print($self->html_report_error()); |
|
#################################### |
|
# Determine table structure # |
# Determine table structure # |
#################################### |
#################################### |
my $num_uneditable = 26; |
my $num_uneditable = 26; |
Line 456 sub compute {
|
Line 455 sub compute {
|
$assess_filename, |
$assess_filename, |
$resource->{'symb'}); |
$resource->{'symb'}); |
my @exportdata = $assessSheet->export_data(); |
my @exportdata = $assessSheet->export_data(); |
if ($assessSheet->badcalc()) { |
|
$self->set_calcerror( |
|
'Error computing row for assessment '. |
|
$assessSheet->get_title().'(row '.$rownum.'):'. |
|
$assessSheet->calcerror()); |
|
} |
|
if ($assessSheet->blackout()) { |
if ($assessSheet->blackout()) { |
$self->blackout(1); |
$self->blackout(1); |
$self->{'blackout_rows'}->{$rownum} = 1; |
$self->{'blackout_rows'}->{$rownum} = 1; |
Line 503 sub compute {
|
Line 496 sub compute {
|
sub set_row_sources { |
sub set_row_sources { |
my $self = shift; |
my $self = shift; |
while (my ($cell,$value) = each(%{$self->{'formulas'}})) { |
while (my ($cell,$value) = each(%{$self->{'formulas'}})) { |
next if ($cell !~ /^A(\d+)/ && $1 > 0); |
next if ($cell !~ /^A(\d+)$/ || $1 < 1); |
my $row = $1; |
my $row = $1; |
(undef,$value) = split('__&&&__',$value); |
(undef,$value) = split('__&&&__',$value); |
$value = 'Default' if (! defined($value)); |
$value = 'Default' if (! defined($value)); |
Line 520 sub set_row_numbers {
|
Line 513 sub set_row_numbers {
|
next if ($row == 0); |
next if ($row == 0); |
my ($symb,undef) = split('__&&&__',$formula); |
my ($symb,undef) = split('__&&&__',$formula); |
$self->{'row_numbers'}->{$symb} = $row; |
$self->{'row_numbers'}->{$symb} = $row; |
$self->{'maxrow'} = $1 if ($1 > $self->{'maxrow'}); |
$self->{'maxrow'} = $row if ($row > $self->{'maxrow'}); |
} |
} |
} |
} |
|
|
Line 550 These rows are saved in the courses dire
|
Line 543 These rows are saved in the courses dire
|
############################################# |
############################################# |
############################################# |
############################################# |
sub load_cached_export_rows { |
sub load_cached_export_rows { |
%Exportrows = undef; |
undef(%Exportrows); |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); |
Line 591 sub save_export_data {
|
Line 584 sub save_export_data {
|
my $self = shift; |
my $self = shift; |
return if ($self->temporary()); |
return if ($self->temporary()); |
my $student = $self->{'name'}.':'.$self->{'domain'}; |
my $student = $self->{'name'}.':'.$self->{'domain'}; |
if ($self->badcalc()){ |
|
# do not save data away when calculations have not been done properly. |
|
delete($Exportrows{$student}); |
|
return; |
|
} |
|
return if (! exists($Exportrows{$student})); |
return if (! exists($Exportrows{$student})); |
return if (! $self->is_default()); |
return if (! $self->is_default()); |
my $key = join(':',($self->{'name'},$self->{'domain'},'studentcalc')).':'; |
my $key = join(':',($self->{'name'},$self->{'domain'},'studentcalc')).':'; |
Line 637 sub export_data {
|
Line 625 sub export_data {
|
! $self->check_expiration_time($Exportrows{$student}->{'time'})) { |
! $self->check_expiration_time($Exportrows{$student}->{'time'})) { |
$self->compute(); |
$self->compute(); |
} |
} |
my @Data; |
my @Data = @{$Exportrows{$student}->{'data'}}; |
if ($self->badcalc()) { |
for (my $i=0; $i<=$#Data;$i++) { |
@Data = (); |
$Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i])); |
} else { |
|
@Data = @{$Exportrows{$student}->{'data'}}; |
|
for (my $i=0; $i<=$#Data;$i++) { |
|
if ($Data[$i]=~/\D/ && defined($Data[$i])) { |
|
$Data[$i]="'".$Data[$i]."'"; |
|
} |
|
} |
|
} |
} |
return @Data; |
return @Data; |
} |
} |