# The LearningOnline Network with CAPA
#
# $Id: lonstudentassessment.pm,v 1.31 2003/03/03 19:28:29 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
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
# (Navigate problems for statistical reports
#
#######################################################
#######################################################
=pod
=head1 NAME
lonstudentassessment
=head1 SYNOPSIS
Presents assessment data about a student or a group of students.
=head1 Subroutines
=over 4
=cut
#######################################################
#######################################################
package Apache::lonstudentassessment;
use strict;
use Apache::lonstatistics;
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
use Apache::lonnet; # for logging porpoises
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;
#######################################################
#######################################################
=pod
=item $show_links 'yes' or 'no' for linking to student performance data
=item $output_mode 'html', 'excel', or 'csv' for output mode
=item $show 'all' or 'totals' determines how much data is output
=cut
#######################################################
#######################################################
my $show_links;
my $output_mode;
my $show;
#######################################################
#######################################################
# End of package variable declarations
=pod
=back
=cut
#######################################################
#######################################################
=pod
=item &BuildStudentAssessmentPage()
Inputs:
=over 4
=item $r Apache Request
=item $c Apache Connection
=back
=cut
#######################################################
#######################################################
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".
ENDMSG
return;
}
#
#
my $initialize = \&html_initialize;
my $output_student = \&html_outputstudent;
my $finish = \&html_finish;
#
if ($output_mode eq 'excel') {
$initialize = \&excel_initialize;
$output_student = \&excel_outputstudent;
$finish = \&excel_finish;
} elsif ($output_mode eq 'csv') {
$initialize = \&csv_initialize;
$output_student = \&csv_outputstudent;
$finish = \&csv_finish;
}
#
if($c->aborted()) { return ; }
#
# Call the initialize routine selected above
$initialize->($r);
foreach my $student (@Apache::lonstatistics::Students) {
if($c->aborted()) {
$finish->($r);
return ;
}
# Call the output_student routine selected above
$output_student->($r,$student);
}
# Call the "finish" routine selected above
$finish->($r);
#
return;
}
#######################################################
#######################################################
sub get_student_fields_to_show {
my @to_show = @Apache::lonstatistics::SelectedStudentData;
foreach (@to_show) {
if ($_ eq 'all') {
@to_show = @Apache::lonstatistics::StudentDataOrder;
last;
}
}
return @to_show;
}
sub get_sequences_to_show {
my @Sequences;
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);
push (@Sequences,$sequence);
}
}
return @Sequences;
}
#######################################################
#######################################################
=pod
=item &CreateInterface()
Called by &BuildStudentAssessmentPage to create the top part of the
page which displays the chart.
Inputs: None
Returns: A string containing the HTML for the headers and top table for
the chart page.
=cut
#######################################################
#######################################################
sub CreateInterface {
my $Str = '';
# $Str .= &CreateLegend();
$Str .= '