--- loncom/interface/spreadsheet/classcalc.pm 2003/05/23 19:36:04 1.3 +++ loncom/interface/spreadsheet/classcalc.pm 2003/05/29 18:31:27 1.7 @@ -1,5 +1,5 @@ # -# $Id: classcalc.pm,v 1.3 2003/05/23 19:36:04 matthew Exp $ +# $Id: classcalc.pm,v 1.7 2003/05/29 18:31:27 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,6 +51,7 @@ use Apache::loncoursedata(); use Apache::lonhtmlcommon(); use Apache::Spreadsheet; use Apache::studentcalc; +use Apache::lonstatistics(); use HTML::Entities(); use Spreadsheet::WriteExcel; use Apache::lonnet; @@ -58,10 +59,23 @@ use Time::HiRes; @Apache::classcalc::ISA = ('Apache::Spreadsheet'); +## +## Package variable +## + +my @Students; + +sub initialize { + &Apache::lonstatistics::clear_classlist_variables(); + @Students = &Apache::lonstatistics::get_students(); + return; +} + sub html_header { my $self = shift; my ($toprow,$bottomrow); - foreach (['Sections','Section selector goes here'], + &Apache::lonstatistics::clear_classlist_variables(); + foreach (['Sections',&Apache::lonstatistics::SectionSelect('Section','multpile',3)], ['Enrollment Status',&Apache::lonhtmlcommon::StatusOptions(undef,undef,3)], ['Output Format',&Apache::Spreadsheet::output_selector()]) { my ($name,$selector) = @{$_}; @@ -74,26 +88,6 @@ sub html_header { "\n
"; } -sub get_classlist { - my $self = shift; - # Retrieve the classlist - my @Students = (); - my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist - ($self->{'cid'},$self->{'cdom'},$self->{'cnum'}); - while (my ($student,$student_data) = each (%$classlist)) { - my $studenthash = (); - for (my $i=0; $i< scalar(@$field_names);$i++) { - my $field = $field_names->[$i]; - $studenthash->{$field}=$student_data->[$i]; - } - # This is where we can skip students because they are in - # the wrong section, have expired or pending roles, whatever... - push (@Students,$studenthash); - } - my @SortedStudents = sort { $a->{'fullname'} cmp $b->{'fullname'} } @Students; - return @SortedStudents; -} - sub get_title { my $self = shift; # Section info should be included @@ -171,7 +165,7 @@ END } # my $num_output = 0; - foreach my $student ($self->get_classlist()) { + foreach my $student (@Students) { if ($num_output++ % 50 == 0) { $r->print("\n".$tableheader); } @@ -192,13 +186,6 @@ END return; } -sub outsheet_csv { - my $self = shift; - my ($r) = @_; - $r->print('