--- loncom/interface/spreadsheet/studentcalc.pm 2003/05/29 18:39:58 1.10 +++ loncom/interface/spreadsheet/studentcalc.pm 2003/09/05 01:57:54 1.18 @@ -1,5 +1,5 @@ # -# $Id: studentcalc.pm,v 1.10 2003/05/29 18:39:58 matthew Exp $ +# $Id: studentcalc.pm,v 1.18 2003/09/05 01:57:54 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,6 +45,9 @@ studentcalc ################################################### package Apache::studentcalc; +use warnings FATAL=>'all'; +no warnings 'uninitialized'; + use strict; use Apache::Constants qw(:common :http); use Apache::lonnet; @@ -65,6 +68,7 @@ my %Exportrows = (); my $current_course; sub initialize { + &Apache::assesscalc::initialize(); &initialize_sequence_cache(); } @@ -97,8 +101,9 @@ sub initialize_sequence_cache { } sub clear_package { - @Sequences = undef; - %Exportrows = undef; + undef(@Sequences); + undef(%Exportrows); + &Apache::assesscalc::clear_package(); } sub get_title { @@ -143,9 +148,29 @@ sub parent_link { return $link; } +sub convenience_links { + my $self = shift; + my ($resource) = @_; + my $symb = &Apache::lonnet::escape($resource->{'symb'}); + my $result = <<"END"; + + + + + + + + + +END + return $result; +} + sub outsheet_html { my $self = shift; my ($r) = @_; + my $importcolor = '#FFFFAA'; + my $exportcolor = '#88FF88'; #################################### # Get the list of assessment files # #################################### @@ -162,7 +187,7 @@ sub outsheet_html { - @@ -171,7 +196,7 @@ END my $label_num = 0; foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){ if ($label_num<$num_uneditable) { - $tableheader .=''. - $self->html_template_row($num_uneditable)."\n"); + $self->html_template_row($num_uneditable, + $importcolor)."\n"); } # # Print out summary/export row $r->print(''. - $self->html_export_row()."\n"); + $self->html_export_row($exportcolor)."\n"); } $r->print("
Student + Import Calculations'; + $tableheader .=''; } else { $tableheader .=''; } @@ -190,12 +215,13 @@ END # Print out template row if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) { $r->print('
Template 
Summary0
\n"); # @@ -204,7 +230,7 @@ END $tableheader =<<"END";

- + END } else { $tableheader =<<"END"; @@ -238,6 +264,7 @@ END my $row_output = ''; if ($editing_is_allowed) { $row_output .= ''; + $row_output .= ''; $row_output .= ''."\n"; } else { - $row_output .= $self->html_row($num_uneditable,$rownum). + $row_output .= $self->html_row($num_uneditable,$rownum, + $exportcolor,$importcolor). "\n"; } $r->print($row_output); @@ -387,7 +415,9 @@ sub outsheet_recursive_excel { sub compute { my $self = shift; - $self->logthis('computing'); + my ($r) = @_; + my $connection = $r->connection(); + if ($connection->aborted()) { $self->cleanup; return; } if (! defined($current_course) || $current_course ne $ENV{'request.course.id'}) { $current_course = $ENV{'request.course.id'}; @@ -414,6 +444,7 @@ sub compute { foreach my $seq (@sequences) { next if ($seq->{'num_assess'}<1); foreach my $resource (@{$seq->{'contents'}}) { + if ($connection->aborted()) { $self->cleanup(); return; } next if ($resource->{'type'} ne 'assessment'); my $rownum = $self->get_row_number_from_key($resource->{'symb'}); my $cell = 'A'.$rownum; @@ -424,11 +455,13 @@ sub compute { $self->{'row_source'}->{$rownum} = $assess_filename; } $f{$cell} = $resource->{'symb'}.'__&&&__'.$assess_filename; + if ($connection->aborted()) { $self->cleanup(); return; } my $assessSheet = Apache::assesscalc->new($self->{'name'}, $self->{'domain'}, $assess_filename, $resource->{'symb'}); - my @exportdata = $assessSheet->export_data(); + my @exportdata = $assessSheet->export_data($r); + if ($connection->aborted()) { $self->cleanup(); return; } if ($assessSheet->blackout()) { $self->blackout(1); $self->{'blackout_rows'}->{$rownum} = 1; @@ -470,7 +503,7 @@ sub compute { sub set_row_sources { my $self = shift; while (my ($cell,$value) = each(%{$self->{'formulas'}})) { - next if ($cell !~ /^A(\d+)/ && $1 > 0); + next if ($cell !~ /^A(\d+)$/ || $1 < 1); my $row = $1; (undef,$value) = split('__&&&__',$value); $value = 'Default' if (! defined($value)); @@ -487,7 +520,7 @@ sub set_row_numbers { next if ($row == 0); my ($symb,undef) = split('__&&&__',$formula); $self->{'row_numbers'}->{$symb} = $row; - $self->{'maxrow'} = $1 if ($1 > $self->{'maxrow'}); + $self->{'maxrow'} = $row if ($row > $self->{'maxrow'}); } } @@ -517,7 +550,7 @@ These rows are saved in the courses dire ############################################# ############################################# sub load_cached_export_rows { - %Exportrows = undef; + undef(%Exportrows); my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); @@ -565,7 +598,7 @@ sub save_export_data { my $newstore = join('___;___', @{$Exportrows{$student}->{'data'}}); $newstore = '___=___'.$newstore; - &Apache::lonnet::put('nohist_calculatedsheets', + my $result= &Apache::lonnet::put('nohist_calculatedsheets', { $key => $newstore, $timekey => $Exportrows{$student}->{'time'} }, $self->{'cdom'}, @@ -589,11 +622,19 @@ spreadsheet only if necessary. ############################################# sub export_data { my $self = shift; + my ($r) = @_; + my $connection = $r->connection(); my $student = $self->{'name'}.':'.$self->{'domain'}; if (! exists($Exportrows{$student}) || + ! defined($Exportrows{$student}) || + ! exists($Exportrows{$student}->{'data'}) || + ! defined($Exportrows{$student}->{'data'}) || + ! exists($Exportrows{$student}->{'time'}) || + ! defined($Exportrows{$student}->{'time'}) || ! $self->check_expiration_time($Exportrows{$student}->{'time'})) { - $self->compute(); + $self->compute($r); } + if ($connection->aborted()) { $self->cleanup(); return; } my @Data = @{$Exportrows{$student}->{'data'}}; for (my $i=0; $i<=$#Data;$i++) { $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i]));
RowAssessment
Row Assessment
'.$rownum.''.$self->convenience_links($resource).''. 'Unavailable at this time