--- loncom/interface/spreadsheet/studentcalc.pm 2003/05/23 14:52:51 1.5
+++ loncom/interface/spreadsheet/studentcalc.pm 2003/05/29 13:39:38 1.8
@@ -1,5 +1,5 @@
#
-# $Id: studentcalc.pm,v 1.5 2003/05/23 14:52:51 matthew Exp $
+# $Id: studentcalc.pm,v 1.8 2003/05/29 13:39:38 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -64,12 +64,24 @@ my %Exportrows = ();
my $current_course;
+sub 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
@@ -91,14 +103,25 @@ sub clear_package {
sub get_title {
my $self = shift;
- my $title = '';
+ my @title = ();
+ #
+ # Determine the students name
my %userenv = &Apache::loncoursedata::GetUserName($self->{'name'},
$self->{'domain'});
- &Apache::lonnet::logthis('userenv = '.join(' ',%userenv));
- my $name =
- join(' ',@userenv{'firstname','middlename','lastname','generation'});
+ my $name = join(' ',
+ @userenv{'firstname','middlename','lastname','generation'});
$name =~ s/\s+$//;
- $title .= '
'.$name;
+
+ push (@title,$name);
+ push (@title,$self->{'coursedesc'});
+ push (@title,scalar(localtime(time)));
+ return @title;
+}
+
+sub get_html_title {
+ my $self = shift;
+ my ($name,$desc,$time) = $self->get_title();
+ my $title = ''.$name;
if ($ENV{'user.name'} ne $self->{'name'} &&
$ENV{'user.domain'} ne $self->{'domain'}) {
$title .= &Apache::loncommon::aboutmewrapper
@@ -106,8 +129,8 @@ sub get_title {
$self->{'name'},$self->{'domain'});
}
$title .= "
\n";
- $title .= ''.$self->{'coursedesc'}."
\n";
- $title .= ''.localtime(time).'
';
+ $title .= ''.$desc."
\n";
+ $title .= ''.$time.'
';
return $title;
}
@@ -301,27 +324,67 @@ 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) = @_;
+ my ($filehandle) = @_;
+ #
+ # Write a header row
+ $self->csv_output_row($filehandle,undef,
+ ('Container','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 outsheet_excel {
+
+sub excel_rows {
+ # writes the meat of the spreadsheet to an excel worksheet. Called
+ # by Spreadsheet::outsheet_excel;
my $self = shift;
- my ($r) = @_;
+ my ($worksheet,$cols_output,$rows_output) = @_;
+ #
+ # Write a header row
+ $cols_output = 0;
+ foreach my $value ('Container','Assessment title') {
+ $worksheet->write($rows_output,$cols_output++,$value);
+ }
+ $rows_output++;
+ #
+ # 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->excel_output_row($worksheet,$rownum,$rows_output++,
+ @assessdata);
+ }
+ }
+ return;
}
+
sub outsheet_recursive_excel {
my $self = shift;
my ($r) = @_;
}
-sub display {
- my $self = shift;
- my ($r) = @_;
- $self->compute();
- $self->outsheet_html($r);
- return;
-}
-
sub set_row_sources {
my $self = shift;
while (my ($cell,$value) = each(%{$self->{'formulas'}})) {