--- loncom/interface/statistics/lonstudentassessment.pm 2002/07/24 14:52:32 1.1
+++ loncom/interface/statistics/lonstudentassessment.pm 2003/03/03 19:28:29 1.31
@@ -1,12 +1,10 @@
# The LearningOnline Network with CAPA
-# (Publication Handler
#
-# $Id: lonstudentassessment.pm,v 1.1 2002/07/24 14:52:32 stredwic Exp $
+# $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
@@ -26,214 +24,677 @@
# 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
#
-###
+#######################################################
+#######################################################
+
+=pod
+
+=head1 NAME
+
+lonstudentassessment
+
+=head1 SYNOPSIS
+
+Presents assessment data about a student or a group of students.
-package Apache::lonstudentassessment;
+=head1 Subroutines
+
+=over 4
+
+=cut
+
+#######################################################
+#######################################################
+
+package Apache::lonstudentassessment;
use strict;
+use Apache::lonstatistics;
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
-use GDBM_File;
+use Apache::lonnet; # for logging porpoises
+use Spreadsheet::WriteExcel;
-sub BuildStudentAssessmentPage {
- my ($cacheDB, $students, $courseID, $c)=@_;
+#######################################################
+#######################################################
+=pod
- my %cache;
+=item Package Variables
- my $Ptr = '';
- $Ptr .= '
';
+=over 4
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- return 'Unable to tie database.';
- }
-
- my $selectedName = $cache{'StudentAssessmentStudent'};
- for(my $index=0;
- ($selectedName ne 'All Students') && ($index<(scalar @$students));
- $index++) {
- my $fullname = $cache{$students->[$index].':fullname'};
- if($fullname eq $selectedName) {
- if($cache{'StudentAssessmentMove'} eq 'next') {
- if($index == ((scalar @$students) - 1)) {
- $selectedName = $students->[0];
- } else {
- $selectedName = $students->[$index+1];
- }
- } elsif($cache{'StudentAssessmentMove'} eq 'previous') {
- if($index == 0) {
- $selectedName = $students->[-1];
- } else {
- $selectedName = $students->[$index-1];
- }
- } else {
- $selectedName = $students->[$index];
- }
+=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;
+}
+
- $Ptr .= '
';
- }
-
- return $Ptr;
-}
-
-#---- Student Assessment Web Page --------------------------------------------
-
-# ------ Create different Student Report
-sub StudentReport {
- my ($cache, $name)=@_;
+#######################################################
+#######################################################
+=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 = '';
- if($cache->{$name.':error'} =~ /course/) {
- my ($username)=split(':',$name);
- $Str .= 'No course data for student ';
- $Str .= ''.$username.'. ';
- return $Str;
- }
-
- $Str .= "
\#
Set Title
";
- $Str .= '
Results
Tries
'."\n";
-
- my $codes;
- my $attempts;
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'StudentAssessmentMap'} ne 'All Maps' &&
- $cache->{'StudentAssessmentMap'} ne $cache->{$sequence.':title'}) {
- next;
- }
-
- $Str .= '
'.$sequence.'
';
- $Str .= '
'.$cache->{$sequence.':title'}.'
';
-
- $codes = '';
- $attempts = '';
- foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
- my $problem = $cache->{$problemID.':problem'};
- my $LatestVersion = $cache->{$name.':version:'.$problem};
-
- # Output dashes for all the parts of this problem if there
- # is no version information about the current problem.
- if(!$LatestVersion) {
- foreach my $part (split(/\:/,$cache->{$sequence.':'.
- $problemID.
- ':parts'})) {
- $codes .= "-,";
- $attempts .= "0,";
- }
- next;
- }
+# $Str .= &CreateLegend();
+ $Str .= '
'."\n";
+ foreach my $S(@$sequenceKeys) {
+ my $title=$cache->{$S.':title'};
+ #$Str .= $cache->{$S.':problems'};
+ #my @problems=split(':', $cache->{$S.':problems'});
+ #my $pCount=scalar @problems;
+ my $pCount=MaxSeqPr($cache,@$students[0],$S);
+ my $crr;
+ if ($StudentCount) {
+ $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount );
+ } else {
+ $crr="0.00";
+ }
+ $Str .= '
'.$title.
+ '
'.$pCount.
+ '
'.$crr.
+ '
'."\n";
}
$Str .= '
'."\n";
@@ -241,6 +702,48 @@ sub StudentReport {
return $Str;
}
-#---- END Student Assessment Web Page ----------------------------------------
+#######################################################
+#######################################################
+
+=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
+
+#######################################################
+#######################################################
+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".
+ "