--- loncom/interface/spreadsheet/classcalc.pm 2003/06/12 17:06:44 1.8 +++ loncom/interface/spreadsheet/classcalc.pm 2003/09/05 01:57:54 1.12 @@ -1,5 +1,5 @@ # -# $Id: classcalc.pm,v 1.8 2003/06/12 17:06:44 matthew Exp $ +# $Id: classcalc.pm,v 1.12 2003/09/05 01:57:54 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 { <table border="2"> <tr> <th colspan="2" rowspan="2"><font size="+2">Course</font></th> - <td bgcolor="#FFDDDD" colspan="$num_uneditable"> + <td bgcolor="$importcolor" colspan="$num_uneditable"> <b><font size="+1">Import</font></b></td> <td colspan="$num_left"> <b><font size="+1">Calculations</font></b></td> @@ -128,7 +137,7 @@ END my $label_num = 0; foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){ if ($label_num<$num_uneditable) { - $tableheader.='<th bgcolor="#FFDDDD">'; + $tableheader.='<th bgcolor="'.$importcolor.'">'; } else { $tableheader.='<th>'; } @@ -141,11 +150,12 @@ END # # Print out template row $r->print('<tr><td>Template</td><td> </td>'. - $self->html_template_row($num_uneditable)."</tr>\n"); + $self->html_template_row($num_uneditable,$importcolor). + "</tr>\n"); # # Print out summary/export row $r->print('<tr><td>Summary</td><td>0</td>'. - $self->html_export_row()."</tr>\n"); + $self->html_export_row($exportcolor)."</tr>\n"); # # Prepare to output rows $tableheader =<<"END"; @@ -157,7 +167,7 @@ END END foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){ if ($label_num<$num_uneditable) { - $tableheader.='<th bgcolor="#FFDDDD">'; + $tableheader.='<th bgcolor="'.$importcolor.'">'; } else { $tableheader.='<th>'; } @@ -180,7 +190,9 @@ END '<td>'.$student->{'domain'} .'</td>'. '<td>'.$student->{'section'} .'</td>'. '<td>'.$student->{'status'} .'</td>'. - $self->html_row($num_uneditable,$rownum)."</tr>\n"); + $self->html_row($num_uneditable,$rownum,$exportcolor, + $importcolor). + "</tr>\n"); } $r->print("</table></p>\n"); return; @@ -250,18 +262,27 @@ 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(); my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin ($r,'Spreadsheet Computation Status', 'Spreadsheet Computation', scalar(@Students)); + &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, + 'Processing course structure'); &Apache::studentcalc::initialize_package(); + &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;