--- loncom/interface/statistics/lonstudentassessment.pm 2003/02/28 21:19:00 1.30
+++ loncom/interface/statistics/lonstudentassessment.pm 2003/04/29 19:46:24 1.45
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentassessment.pm,v 1.30 2003/02/28 21:19:00 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.45 2003/04/29 19:46:24 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -54,7 +54,23 @@ use Apache::lonstatistics;
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
use Apache::lonnet; # for logging porpoises
-use GDBM_File;
+use Spreadsheet::WriteExcel;
+
+#######################################################
+#######################################################
+=pod
+
+=item Package Variables
+
+=over 4
+
+=item $Statistics Hash ref to store student data. Indexed by symb,
+ contains hashes with keys 'score' and 'max'.
+
+=cut
+
+#######################################################
+#######################################################
my $Statistics;
@@ -63,27 +79,40 @@ my $Statistics;
=pod
-=item &BuildStudentAssessmentPage()
+=item $show_links 'yes' or 'no' for linking to student performance data
-Inputs:
+=item $output_mode 'html', 'excel', or 'csv' for output mode
-=over 4
+=item $show 'all', 'totals', or 'scores' determines how much data is output
-=item $cacheDB The name of the cache file used to store student data
+=cut
-=item $students Array ref containing the name(s) of the students
-selected for display
+#######################################################
+#######################################################
+my $show_links;
+my $output_mode;
+my $show;
-=item $courseID The ID of the course
+#######################################################
+#######################################################
+# End of package variable declarations
-=item $formName The name of the html form - 'Statistics'
+=pod
-=item $headings Array ref of headings to show
+=back
+
+=cut
-=item $spacing A string of spaces
+#######################################################
+#######################################################
-=item $studentInformation Array ref of possible headings for student info
-('fullname','section',...)
+=pod
+
+=item &BuildStudentAssessmentPage()
+
+Inputs:
+
+=over 4
=item $r Apache Request
@@ -98,36 +127,80 @@ selected for display
sub BuildStudentAssessmentPage {
my ($r,$c)=@_;
undef($Statistics);
-
#
+ # Print out the HTML headers for the interface
+ # This also parses the output mode selector
+ # This step must always be done.
$r->print(&CreateInterface());
+ $r->print('');
$r->rflush();
+ if (! exists($ENV{'form.notfirstrun'})) {
+ $r->print(<
+
+Please make your selections in the boxes above and hit
+the button marked "Update Display".
+
+
'."\n";
$Str .= ''."\n";
return $Str;
}
-
#######################################################
#######################################################
=pod
-=item Table Output Routines
-
-=over 4
+=item &CreateAndParseOutputSelector()
=cut
#######################################################
#######################################################
-{
- my $padding;
+my @OutputOptions =
+ ({ name => 'HTML, with links',
+ value => 'html, with links',
+ description => 'Output HTML with each symbol linked to the problem '.
+ 'which generated it.',
+ mode => 'html',
+ show => 'all',
+ show_links => 'yes',
+ },
+ { name => 'HTML, without links',
+ value => 'html, without links',
+ description => 'Output HTML. By not including links, the size of the'.
+ ' web page is greatly reduced. If your browser crashes on the '.
+ 'full display, try this.',
+ mode => 'html',
+ show => 'all',
+ show_links => 'no',
+ },
+ { name => 'HTML, scores only',
+ value => 'html, scores only',
+ description => 'Output HTML, only showing the total number of correct'.
+ ' problems (or problem parts) and not the maximum possible for '.
+ 'each student',
+ mode => 'html',
+ show => 'scores',
+ show_links => 'no',
+ },
+ { name => 'HTML, totals',
+ value => 'html, totals',
+ description => 'Output HTML, but only the summary statistics for each'.
+ ' sequence selected for each student.',
+ mode => 'html',
+ show => 'totals',
+ show_links => 'no',
+ },
+ { name => 'HTML, summary table only',
+ value => 'html summary table only',
+ description => 'Output HTML, but only the final summary table for '.
+ 'all students across all sequences.',
+ mode => 'html',
+ show => 'final table',
+ show_links => 'no',
+ },
+ { name => 'Excel, scores only',
+ value => 'excel, scores only',
+ description => 'Output an Excel file (compatable with Excel 95), '.
+ 'with a single column for each sequence showing the students '.
+ 'score.',
+ mode => 'excel',
+ show => 'scores',
+ show_links => 'no',
+ },
+ { name => 'Excel, totals',
+ value => 'excel, totals',
+ description => 'Output an Excel file (compatable with Excel 95), '.
+ 'with two columns for each sequence, the students score on the '.
+ 'sequence and the students maximum possible on the sequence',
+ mode => 'excel',
+ show => 'totals',
+ show_links => 'no',
+ },
+ { name => 'multi-sheet Excel',
+ value => 'multi-sheet excel',
+ description => 'Output an Excel file (compatable with Excel 95), '.
+ 'with a seperate worksheet for each sequence you have selected '.
+ 'the data for each problem part '.
+ '(number of tries, status, points awarded) will be listed.',
+ mode => 'multi-sheet excel',
+ show => 'totals',
+ show_links => 'no',
+ },
+ { name => 'multi-sheet Excel, by section',
+ value => 'multi-sheet excel, by section',
+ description => 'Output an Excel file (compatable with Excel 95), '.
+ 'with a seperate worksheet for each sequence you have selected '.
+ 'the data for each problem part '.
+ '(number of tries, status, points awarded) will be listed. '.
+ 'There will be one Excel workbook for each section selected.',
+ mode => 'multi-sheet excel',
+ show => 'by section',
+ show_links => 'no',
+ },
+ { name => 'CSV, everything',
+ value => 'csv, everything',
+ description => '',
+ mode => 'csv',
+ show => 'all',
+ show_links => 'no',
+ },
+ { name => 'CSV, scores only',
+ value => 'csv, scores only',
+ description => '',
+ mode => 'csv',
+ show => 'scores',
+ show_links => 'no',
+ },
+ { name => 'CSV, totals',
+ value => 'csv, totals',
+ description => '',
+ mode => 'csv',
+ show => 'totals',
+ show_links => 'no',
+ },
+ );
-#######################################################
-#######################################################
-
-=pod
-
-=item &CreateTableHeadings()
-
-Create HTML for the columns of student data to show.
-Called by &BuildStudentAssessmentPage(). Calls
-&Apache::lonhtmlcommon::CreateHeadings().
+sub OutputDescriptions {
+ my $Str = '';
+ $Str .= "
Output Modes
\n";
+ $Str .= "
\n";
+ foreach my $outputmode (@OutputOptions) {
+ $Str .="
".$outputmode->{'name'}."
\n";
+ $Str .="
".$outputmode->{'description'}."
\n";
+ }
+ $Str .= "
\n";
+ return $Str;
+}
-Inputs:
+sub CreateAndParseOutputSelector {
+ my $Str = '';
+ my $elementname = 'chartoutputmode';
+ #
+ # Format for output options is 'mode, restrictions';
+ my $selected = 'html, with links';
+ if (exists($ENV{'form.'.$elementname})) {
+ if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
+ $selected = $ENV{'form.'.$elementname}->[0];
+ } else {
+ $selected = $ENV{'form.'.$elementname};
+ }
+ }
+ #
+ # Set package variables describing output mode
+ $show_links = 'no';
+ $output_mode = 'html';
+ $show = 'all';
+ foreach my $option (@OutputOptions) {
+ next if ($option->{'value'} ne $selected);
+ $output_mode = $option->{'mode'};
+ $show = $option->{'show'};
+ $show_links = $option->{'show_links'};
+ }
-=over 4
+ #
+ # Build the form element
+ $Str = qq/";
+ return $Str;
+}
-=item $cache The ubiquitous cache
+#######################################################
+#######################################################
-=item $spacing A string of spaces
+=pod
-=item $infoKeys Array ref to names of keys to display from the cache
-which describe students
+=head2 HTML output routines
-=item $infoHeadings Array ref to headings of columns for student info
+=item &html_initialize($r)
-=item $sequenceKeys Array ref of names of keys to use to retrieve sequence
-data from the cache
+Create labels for the columns of student data to show.
-=item $sequenceHeadings Array ref of names of sequences used for output.
+=item &html_outputstudent($r,$student)
-=back
+Return a line of the chart for a student.
-Returns: A string containing the HTML of the table headings.
+=item &html_finish($r)
=cut
#######################################################
#######################################################
-sub CreateTableHeadings {
+{
+ my $padding;
+ my $count;
+
+ my $nodata_count; # The number of students for which there is no data
+ my %prog_state; # progress state used by loncommon PrgWin routines
+
+sub html_initialize {
+ my ($r) = @_;
#
$padding = ' 'x3;
+ $count = 0;
+ $nodata_count = 0;
#
- my $Str = '
';
- # First, the @StudentData fields need to be listed
- my @to_show = @Apache::lonstatistics::SelectedStudentData;
- foreach (@to_show) {
- if ($_ eq 'all') {
- @to_show = @Apache::lonstatistics::StudentDataOrder;
- last;
- }
+ $r->print("
");
+
+ #
+ # Set up progress window for 'final table' display only
+ if ($show eq 'final table') {
+ my $studentcount = scalar(@Apache::lonstatistics::Students);
+ %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
+ ($r,'Summary Table Status',
+ 'Summary Table Compilation Progress', $studentcount);
}
+ my $Str = "
\n";
+ # First, the @StudentData fields need to be listed
+ my @to_show = &get_student_fields_to_show();
foreach my $field (@to_show) {
my $title=$Apache::lonstatistics::StudentData{$field}->{'title'};
my $base =$Apache::lonstatistics::StudentData{$field}->{'base_width'};
@@ -249,48 +472,36 @@ sub CreateTableHeadings {
$Str .= $title.' 'x($width-$base).$padding;
}
# Now the selected sequences need to be listed
- foreach my $map_symb (@Apache::lonstatistics::SelectedMaps) {
- foreach my $sequence (@Apache::lonstatistics::Sequences) {
- next if ($sequence->{'symb'} ne $map_symb && $map_symb ne 'all');
- next if ($sequence->{'num_assess'} < 1);
- my $title = $sequence->{'title'};
- my $base = $sequence->{'base_width'};
- my $width = $sequence->{'width'};
- $Str .= $title.' 'x($width-$base).$padding;
- }
+ foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()){
+ my $title = $sequence->{'title'};
+ my $base = $sequence->{'base_width'};
+ my $width = $sequence->{'width'};
+ $Str .= $title.' 'x($width-$base).$padding;
}
- $Str .= 'total';
- $Str .= "