--- loncom/interface/spreadsheet/classcalc.pm 2003/06/23 16:06:11 1.9 +++ loncom/interface/spreadsheet/classcalc.pm 2003/09/10 14:47:42 1.13 @@ -1,5 +1,5 @@ # -# $Id: classcalc.pm,v 1.9 2003/06/23 16:06:11 matthew Exp $ +# $Id: classcalc.pm,v 1.13 2003/09/10 14:47:42 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,8 @@ classcalc package Apache::classcalc; use strict; +use warnings FATAL=>'all'; +no warnings 'uninitialized'; use Apache::Constants qw(:common :http); use Apache::loncoursedata(); use Apache::lonhtmlcommon(); @@ -71,6 +73,11 @@ sub initialize { return; } +sub clear_package { + undef(@Students); + &Apache::studentcalc::clear_package(); +} + sub html_header { my $self = shift; my ($toprow,$bottomrow); @@ -112,6 +119,8 @@ sub outsheet_html { ################################### # Determine table structure ################################### + my $importcolor = '#88FF88'; + my $exportcolor = '#BBBBFF'; my $num_uneditable = 26; my $num_left = 52-$num_uneditable; my $tableheader =<<"END"; @@ -119,7 +128,7 @@ sub outsheet_html { - @@ -128,7 +137,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"); # # Prepare to output rows $tableheader =<<"END"; @@ -157,7 +167,7 @@ END END foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){ if ($label_num<$num_uneditable) { - $tableheader.=''. ''. ''. - $self->html_row($num_uneditable,$rownum)."\n"); + $self->html_row($num_uneditable,$rownum,$exportcolor, + $importcolor). + "\n"); } $r->print("
Course + Import Calculations'; + $tableheader.=''; } else { $tableheader.=''; } @@ -141,11 +150,12 @@ END # # Print out template row $r->print('
Template 
Summary0
'; + $tableheader.=''; } else { $tableheader.=''; } @@ -180,7 +190,9 @@ END ''.$student->{'domain'} .''.$student->{'section'} .''.$student->{'status'} .'

\n"); return; @@ -190,11 +202,11 @@ sub excel_rows { # writes the meat of the spreadsheet to an excel worksheet. Called # by Spreadsheet::outsheet_excel; my $self = shift; - my ($worksheet,$cols_output,$rows_output) = @_; + my ($connection,$worksheet,$cols_output,$rows_output) = @_; # # Write a header row $cols_output = 0; - foreach my $value ('fullname','username','domain','section','status') { + foreach my $value ('fullname','username','domain','section','status','id') { $worksheet->write($rows_output,$cols_output++,$value); } $rows_output++; @@ -209,7 +221,8 @@ sub excel_rows { $student->{'username'}, $student->{'domain'}, $student->{'section'}, - $student->{'status'}); + $student->{'status'}, + $student->{'id'}); $self->excel_output_row($worksheet,$rownum,$rows_output++, @studentdata); } @@ -220,12 +233,12 @@ sub csv_rows { # writes the meat of the spreadsheet to an excel worksheet. Called # by Spreadsheet::outsheet_excel; my $self = shift; - my ($filehandle) = @_; + my ($connection,$filehandle) = @_; # # Write a header row $self->csv_output_row($filehandle,undef, - ('fullname','username','domain','section','status')); + ('fullname','username','domain','section','status','id')); # # Write each students row foreach my $student (@Students) { @@ -236,7 +249,8 @@ sub csv_rows { $student->{'username'}, $student->{'domain'}, $student->{'section'}, - $student->{'status'}); + $student->{'status'}, + $student->{'id'}); $self->csv_output_row($filehandle,$rownum,@studentdata); } return; @@ -250,6 +264,8 @@ sub outsheet_recursive_excel { sub compute { my $self = shift; my ($r) = @_; + my $connection = $r->connection(); + if ($connection->aborted()) { $self->cleanup(); return; } $self->initialize_safe_space(); my %c = $self->constants(); my %f = $self->formulas(); @@ -262,10 +278,13 @@ sub compute { &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, 'Processing first student'); foreach my $student (@Students) { + if ($connection->aborted()) { $self->cleanup(); return; } my $sname = $student->{'username'}.':'.$student->{'domain'}; my $studentsheet = Apache::studentcalc->new ($student->{'username'},$student->{'domain'},undef); - my @exportdata = $studentsheet->export_data(); + if ($connection->aborted()) { $self->cleanup(); return; } + my @exportdata = $studentsheet->export_data($r); + if ($connection->aborted()) { $self->cleanup(); return; } my $rownum = $self->get_row_number_from_key($sname); $f{'A'.$rownum} = $sname; $self->{'row_source'}->{$rownum} = $sname;