--- loncom/interface/statistics/lonstudentassessment.pm 2002/08/13 00:37:18 1.8
+++ loncom/interface/statistics/lonstudentassessment.pm 2003/02/28 21:19:00 1.30
@@ -1,12 +1,10 @@
# The LearningOnline Network with CAPA
-# (Publication Handler
#
-# $Id: lonstudentassessment.pm,v 1.8 2002/08/13 00:37:18 stredwic Exp $
+# $Id: lonstudentassessment.pm,v 1.30 2003/02/28 21:19:00 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
-#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -26,559 +24,535 @@
# http://www.lon-capa.org/
#
# (Navigate problems for statistical reports
-# YEAR=2001
-# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
-# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
-# YEAR=2002
-# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
-# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
#
-###
+#######################################################
+#######################################################
-package Apache::lonstudentassessment;
+=pod
-use strict;
-use Apache::lonhtmlcommon;
-use Apache::loncoursedata;
-use GDBM_File;
+=head1 NAME
-#my $jr;
+lonstudentassessment
-sub BuildStudentAssessmentPage {
- my ($cacheDB,$students,$courseID,$formName,$headings,$spacing,
- $studentInformation,$r,$c)=@_;
-# $jr = $r;
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- $r->print('
'."\n";
+=item &BuildStudentAssessmentPage()
- return $Str;
-}
+Inputs:
-=pod
+=over 4
-=item &FormatStudentData()
+=item $cacheDB The name of the cache file used to store student data
-First, FormatStudentInformation is called and prefixes the course information.
-This function produces a formatted string of the student's course information.
-Each column of data represents all the problems for a given sequence. For
-valid grade data, a link is created for that problem to a submission record
-for that problem.
+=item $students Array ref containing the name(s) of the students
+selected for display
-=over 4
+=item $courseID The ID of the course
-Input: $name, $studentInformation, $ChartDB
+=item $formName The name of the html form - 'Statistics'
-$name: The name and domain of the current student in name:domain format
+=item $headings Array ref of headings to show
-$studentInformation: A pointer to an array holding the names used to
-remove data from the hash. They represent
-the name of the data to be removed.
+=item $spacing A string of spaces
-$ChartDB: The name of the cached data database which will be tied to that
-database.
+=item $studentInformation Array ref of possible headings for student info
+('fullname','section',...)
-Output: $Str
+=item $r Apache Request
-$Str: Formatted string that is an entire row of the chart. It is a
-concatenation of student information and student course information.
+=item $c Apache Connection
=back
=cut
-sub StudentReport {
- my ($cache,$name,$spacing,$showSequences)=@_;
- my ($username,$domain)=split(':',$name);
+#######################################################
+#######################################################
+sub BuildStudentAssessmentPage {
+ my ($r,$c)=@_;
+ undef($Statistics);
+
+ #
+ $r->print(&CreateInterface());
+ $r->rflush();
+ #
+ $r->print(&CreateTableHeadings());
+ if($c->aborted()) { return ; }
+
+ my $Count = 0;
+ $r->print('
'."\n");
+ my $Str;
+ return;
+}
- foreach my $sequence (@$showSequences) {
- my $characterCount=0;
- foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
- my $problem = $cache->{$problemID.':problem'};
- # All grades (except for versionless parts) are displayed as links
- # to their submission record. Loop through all the parts for the
- # current problem in the correct order and prepare the output links
- foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
- ':parts'})) {
- $characterCount++;
- if(defined($cache->{$name.':'.$problemID.':NoVersion'}) ||
- $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ') {
- $Str .= ' ';
- next;
- }
- $Str .= '';
- my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
- my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
- if($code eq '*' && $tries < 10 && $tries ne '') {
- $code = $tries;
- }
- $Str .= $code;
- $Str.='';
- }
- }
+#######################################################
+#######################################################
- # Output the number of correct answers for the current sequence.
- # This part takes up 6 character slots, but is formated right
- # justified.
- my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
- $spacesNeeded -= 3;
- $Str .= (' 'x$spacesNeeded);
-
- my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
- ':problemsCorrect'});
- $Str .= ''.$outputProblemsCorrect.'';
- $Str .= $spacing;
- }
-
- # Output the total correct problems over the total number of problems.
- # I don't like this type of formatting, but it is a solution. Need
- # a way to dynamically determine the space requirements.
- my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
- my $outputTotalProblems = sprintf("%4d", $cache->{$name.':totalProblems'});
- $Str .= ''.$outputProblemsSolved.
- ' / '.$outputTotalProblems.'';
+=pod
- return $Str;
-}
+=item &CreateInterface()
-=pod
+Called by &BuildStudentAssessmentPage to create the top part of the
+page which displays the chart.
-=item &CreateLegend()
+Inputs: None
-This function returns a formatted string containing the legend for the
-chart. The legend describes the symbols used to represent grades for
-problems.
+Returns: A string containing the HTML for the headers and top table for
+the chart page.
=cut
-sub CreateLegend {
- my $Str = "
".
- "1..9: correct by student in 1..9 tries\n".
- " *: correct by student in more than 9 tries\n".
- " +: correct by override\n".
- " -: incorrect by override\n".
- " .: incorrect attempted\n".
- " #: ungraded attempted\n".
- " : not attempted\n".
- " x: excused".
- "
'."\n";
return $Str;
}
-=pod
-=item &CreateColumnSelectionBox()
+#######################################################
+#######################################################
-If there are columns not being displayed then this selection box is created
-with a list of those columns. When selections are made and the page
-refreshed, the columns will be removed from this box and the column is
-put back in the chart. If there is no columns to select, no row is added
-to the interface table.
+=pod
+
+=item Table Output Routines
=over 4
-Input: $CacheData, $headings
+=cut
-$CacheData: A pointer to a hash tied to the cached data
+#######################################################
+#######################################################
+{
+ my $padding;
-$headings: An array of the names of the columns for the student information.
-They are used for displaying which columns are missing.
+#######################################################
+#######################################################
-Output: $notThere
+=pod
-$notThere: The string contains one row of a table. The first column has the
-name of the selection box. The second contains the selection box
-which has a size of four.
+=item &CreateTableHeadings()
-=back
+Create HTML for the columns of student data to show.
+Called by &BuildStudentAssessmentPage(). Calls
+&Apache::lonhtmlcommon::CreateHeadings().
-=cut
+Inputs:
-sub CreateColumnSelectionBox {
- my ($doNotShow)=@_;
+=over 4
- my $notThere = '';
- $notThere .= '';
+=item $infoKeys Array ref to names of keys to display from the cache
+which describe students
- return $notThere;
-}
+=item $infoHeadings Array ref to headings of columns for student info
-=pod
+=item $sequenceKeys Array ref of names of keys to use to retrieve sequence
+data from the cache
-=item &CreateColumnSelectors()
+=item $sequenceHeadings Array ref of names of sequences used for output.
-This function generates the checkboxes above the column headings. The
-column will be removed if the checkbox is unchecked.
+=back
-=over 4
+Returns: A string containing the HTML of the table headings.
-Input: $CacheData, $headings
+=cut
-$CacheData: A pointer to a hash tied to the cached data
+#######################################################
+#######################################################
+sub CreateTableHeadings {
+ #
+ $padding = ' 'x3;
+ #
+ 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;
+ }
+ }
+ foreach my $field (@to_show) {
+ my $title=$Apache::lonstatistics::StudentData{$field}->{'title'};
+ my $base =$Apache::lonstatistics::StudentData{$field}->{'base_width'};
+ my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
+ $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;
+ }
+ }
+ $Str .= 'total';
+ $Str .= "
\n";
+ return $Str;
+}
-$headings: An array of the names of the columns for the student
-information. They are used to know what are the student information columns
+#######################################################
+#######################################################
-Output: $present
+=pod
-$present: The string contains the first row of a table. Each column contains
-a checkbox which is left justified. Currently left justification is used
-for consistency of location over the column in which it presides.
+=item &ChartOutputStudent($student)
-=back
+Return a line of the chart for a student.
=cut
-sub CreateColumnSelectors {
- my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
-
- my $present = '';
- for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
- $present .= '
'."\n";
+
+ return $Str;
+}
+
+#######################################################
+#######################################################
+
+=pod
+
+=item &CreateLegend()
+
+This function returns a formatted string containing the legend for the
+chart. The legend describes the symbols used to represent grades for
+problems.
+
+=cut
- return (\@infoHeadings, \@infoKeys, \@sequenceHeadings,
- \@sequenceKeys, \%doNotShow);
+#######################################################
+#######################################################
+sub CreateLegend {
+ my $Str = "
".
+ " 1 correct by student in 1 try\n".
+ " 7 correct by student in 7 tries\n".
+ " * correct by student in more than 9 tries\n".
+ " + correct by hand grading or override\n".
+ " - incorrect by override\n".
+ " . incorrect attempted\n".
+ " # ungraded attempted\n".
+ " not attempted (blank field)\n".
+ " x excused".
+ "