--- loncom/interface/statistics/lonproblemstatistics.pm 2003/06/02 13:58:43 1.51
+++ loncom/interface/statistics/lonproblemstatistics.pm 2004/03/23 20:08:58 1.72
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.51 2003/06/02 13:58:43 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.72 2004/03/23 20:08:58 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,11 +51,21 @@ package Apache::lonproblemstatistics;
use strict;
use Apache::lonnet();
+use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
use Apache::lonstatistics;
+use Apache::lonlocal;
use Spreadsheet::WriteExcel;
-
+use Apache::lonstathelpers();
+use Time::HiRes;
+##
+## Localization notes:
+##
+## in @Fields[0]->{'long_title'} is placed in Excel files and is used as the
+## header for plots created with Graph.pm, both of which more than likely do
+## not support localization.
+##
my @Fields = (
{ name => 'problem_num',
title => 'P#',
@@ -75,7 +85,8 @@ my @Fields = (
{ name => 'part',
title => 'Part',
align => 'left',
- color => '#FFFFE6' },
+ color => '#FFFFE6',
+ },
{ name => 'num_students',
title => '#Stdnts',
align => 'right',
@@ -131,12 +142,13 @@ my @Fields = (
format => '%5.2f',
sortable => 'yes',
graphable => 'yes',
- long_title => 'Degree of Difficulty' },
+ long_title => 'Degree of Difficulty'.
+ '[ 1 - ((#YES+#yes) / Tries) ]'},
{ name => 'num_solved',
title => '#YES',
align => 'right',
color => '#FFDDDD',
- format => '%d',
+ format => '%4.1f',# format => '%d',
sortable => 'yes',
graphable => 'yes',
long_title => 'Number of Students able to Solve' },
@@ -144,7 +156,7 @@ my @Fields = (
title => '#yes',
align => 'right',
color => '#FFDDDD',
- format => '%d',
+ format => '%4.1f',# format => '%d',
sortable => 'yes',
graphable => 'yes',
long_title => 'Number of Students given Override' },
@@ -155,7 +167,16 @@ my @Fields = (
format => '%4.1f',
sortable => 'yes',
graphable => 'yes',
- long_title => 'Percent Wrong' },
+ long_title => 'Percent of students whose final answer is wrong' },
+ { name => 'deg_of_disc',
+ title => 'Deg of Disc',
+ align => 'right',
+ color => '#FFFFE6',
+ format => '%4.2f',
+ sortable => 'yes',
+ graphable => 'yes',
+ long_title => 'Degree of Discrimination' },
+
);
###############################################
@@ -172,14 +193,41 @@ select sections, maps, and output.
###############################################
###############################################
+my @OutputOptions =
+ (
+ { name => 'grouped by sequence',
+ value => 'HTML problem statistics grouped',
+ description => 'Output statistics for the problem parts.',
+ mode => 'html',
+ show => 'grouped',
+ },
+ { name => 'ungrouped',
+ value => 'HTML problem statistics ungrouped',
+ description => 'Output statistics for the problem parts.',
+ mode => 'html',
+ show => 'ungrouped',
+ },
+ { name => 'Excel',
+ value => 'Excel problem statistics',
+ description => 'Output statistics for the problem parts '.
+ 'in an Excel workbook',
+ mode => 'excel',
+ show => 'all',
+ },
+ );
+
sub CreateInterface {
my $Str = '';
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Overall Problem Statistics','Statistics_Overall_Key');
$Str .= '
'."\n";
- return $Str;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &CreateAndParseOutputSelector()
-
-Construct a selection list of options for output and parse output selections.
-The current output selected is indicated by the values of the two package
-variables $output_mode and $show. @OutputOptions holds the descriptions of
-the output options and the values for $output_mode and $show.
-
-Based on code from lonstudentassessment.pm.
-
-=cut
-
-#######################################################
-#######################################################
-my $output_mode;
-my $show;
-
-my @OutputOptions =
- (
- { name => 'problem statistics grouped by sequence',
- value => 'HTML problem statistics grouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'grouped',
- },
- { name => 'problem statistics ungrouped',
- value => 'HTML problem statistics ungrouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'ungrouped',
- },
- { name => 'problem statistics, Excel',
- value => 'Excel problem statistics',
- description => 'Output statistics for the problem parts '.
- 'in an Excel workbook',
- mode => 'excel',
- show => 'all',
- },
- );
-
-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;
-}
-
-sub CreateAndParseOutputSelector {
- my $Str = '';
- my $elementname = 'statsoutputmode';
- #
- # Format for output options is 'mode, restrictions';
- my $selected = 'HTML problem statistics grouped';
- 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
- $output_mode = 'html';
- $show = 'all';
- foreach my $option (@OutputOptions) {
- next if ($option->{'value'} ne $selected);
- $output_mode = $option->{'mode'};
- $show = $option->{'show'};
- }
- #
- # Build the form element
- $Str = qq/";
- return $Str;
-}
-
-###############################################
-###############################################
-
-=pod
-
-=item &Gather_Student_Data()
-
-Ensures all student data is up to date.
-
-=cut
-
-###############################################
-###############################################
-sub Gather_Student_Data {
- my ($r) = @_;
- my $c = $r->connection();
- #
- my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
- #
- my @Students = @Apache::lonstatistics::Students;
- #
- # Open the progress window
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
- ($r,'Statistics Compilation Status',
- 'Statistics Compilation Progress', scalar(@Students));
- #
- while (my $student = shift @Students) {
- return if ($c->aborted());
- my ($status,undef) = &Apache::loncoursedata::ensure_current_data
- ($student->{'username'},$student->{'domain'},
- $ENV{'request.course.id'});
- &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- 'last student');
- }
- &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
- $r->rflush();
+ $Str .= '';
+ $Str .= ' 'x5;
+ $Str .= '';
+ $Str .= ' 'x5;
+ return ($Str,$outputmode,$show);
}
###############################################
@@ -353,34 +280,47 @@ Main interface to problem statistics.
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
#
- $output_mode = 'html';
- $show = 'grouped';
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'statsoutputmode' => 'scalar',
+ 'Section' => 'array',
+ 'StudentData' => 'array',
+ 'Maps' => 'array');
+ &Apache::loncommon::store_course_settings('statistics',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('statistics',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
#
- $r->print(&CreateInterface());
+ &Apache::loncoursedata::populate_weight_table();
+ #
+ my ($interface,$output_mode,$show) = &CreateInterface();
+ $r->print($interface);
$r->print('');
$r->print('');
$r->print('');
if (! exists($ENV{'form.statsfirstcall'})) {
- $r->print(<
-
-Please make your selections in the boxes above and hit
-the button marked "Update Display".
-
-
-ENDMSG
return;
}
#
- &Gather_Student_Data($r);
+ &Apache::lonstatistics::Gather_Student_Data($r);
#
#
if ($output_mode eq 'html') {
$r->print("
");
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ if (defined($starttime) || defined($endtime)) {
+ # Inform the user what the time limits on the data are.
+ $r->print('
'.&mt('Statistics on submissions from [_1] to [_2]',
+ &Apache::lonlocal::locallocaltime($starttime),
+ &Apache::lonlocal::locallocaltime($endtime)).
+ '
');
+ }
+ $r->print("
".&mt('Compiled on [_1]',
+ &Apache::lonlocal::locallocaltime(time))."