--- loncom/interface/spreadsheet/studentcalc.pm 2003/05/23 19:36:04 1.6 +++ loncom/interface/spreadsheet/studentcalc.pm 2003/07/16 15:57:32 1.14 @@ -1,5 +1,5 @@ # -# $Id: studentcalc.pm,v 1.6 2003/05/23 19:36:04 matthew Exp $ +# $Id: studentcalc.pm,v 1.14 2003/07/16 15:57:32 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -64,12 +64,25 @@ my %Exportrows = (); my $current_course; +sub initialize { + &Apache::assesscalc::initialize(); + &initialize_sequence_cache(); +} + sub initialize_package { $current_course = $ENV{'request.course.id'}; &initialize_sequence_cache(); &load_cached_export_rows(); } +sub ensure_correct_sequence_data { + if ($current_course ne $ENV{'request.course.id'}) { + &initialize_sequence_cache(); + $current_course = $ENV{'request.course.id'}; + } + return; +} + sub initialize_sequence_cache { # # Set up the sequences and assessments @@ -131,9 +144,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 # #################################### @@ -150,7 +183,7 @@ sub outsheet_html { - @@ -159,7 +192,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 .=''; } @@ -178,12 +211,13 @@ END # Print out template row if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) { $r->print('
Template 
Summary0
\n"); # @@ -192,7 +226,7 @@ END $tableheader =<<"END";

- + END } else { $tableheader =<<"END"; @@ -226,6 +260,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); @@ -312,10 +348,30 @@ sub modify_cell { return; } -sub outsheet_csv { +sub csv_rows { + # writes the meat of the spreadsheet to an excel worksheet. Called + # by Spreadsheet::outsheet_excel; my $self = shift; - my ($r) = @_; - $r->print('

csv output is not supported yet

'); + my ($filehandle) = @_; + # + # Write a header row + $self->csv_output_row($filehandle,undef, + ('Sequence or Folder','Assessment title')); + # + # Write each assessments row + if (scalar(@Sequences)< 1) { + &initialize_sequence_cache(); + } + foreach my $Sequence (@Sequences) { + next if ($Sequence->{'num_assess'} < 1); + foreach my $resource (@{$Sequence->{'contents'}}) { + my $rownum = $self->get_row_number_from_key($resource->{'symb'}); + my @assessdata = ($Sequence->{'title'}, + $resource->{'title'}); + $self->csv_output_row($filehandle,$rownum,@assessdata); + } + } + return; } sub excel_rows { @@ -353,18 +409,6 @@ sub outsheet_recursive_excel { my ($r) = @_; } -sub set_row_sources { - my $self = shift; - while (my ($cell,$value) = each(%{$self->{'formulas'}})) { - next if ($cell !~ /^A(\d+)/ && $1 > 0); - my $row = $1; - (undef,$value) = split('__&&&__',$value); - $value = 'Default' if (! defined($value)); - $self->{'row_source'}->{$row} = $value; - } - return; -} - sub compute { my $self = shift; $self->logthis('computing'); @@ -442,6 +486,20 @@ sub compute { $Exportrows{$student}->{'data'} = \@exportarray; # save export row $self->save_export_data(); + # + $self->save() if ($self->need_to_save()); + return; +} + +sub set_row_sources { + my $self = shift; + while (my ($cell,$value) = each(%{$self->{'formulas'}})) { + next if ($cell !~ /^A(\d+)/ && $1 > 0); + my $row = $1; + (undef,$value) = split('__&&&__',$value); + $value = 'Default' if (! defined($value)); + $self->{'row_source'}->{$row} = $value; + } return; } @@ -453,6 +511,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'}); } }
RowAssessment
Row Assessment
'.$rownum.''.$self->convenience_links($resource).''. 'Unavailable at this time