--- loncom/interface/statistics/lonproblemstatistics.pm 2004/05/18 18:12:19 1.86
+++ loncom/interface/statistics/lonproblemstatistics.pm 2009/03/05 09:12:14 1.117
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.86 2004/05/18 18:12:19 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.117 2009/03/05 09:12:14 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,7 +50,7 @@ Excel files, and plots.
package Apache::lonproblemstatistics;
use strict;
-use Apache::lonnet();
+use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
@@ -60,6 +60,8 @@ use Apache::lonlocal;
use Spreadsheet::WriteExcel;
use Apache::lonstathelpers();
use Time::HiRes;
+use LONCAPA;
+
my @StatsArray;
my %SeqStat; # keys are symbs, values are hash refs
@@ -121,11 +123,11 @@ my @Fields = (
align => 'left',
color => '#FFFFE6',
special => 'link',
- sortable => 'yes',
+ sortable => 'yes',
selectable => 'no',
defaultselected => 'yes',
},
- { name => 'part',
+ { name => 'part',
title => 'Part',
align => 'left',
color => '#FFFFE6',
@@ -231,6 +233,17 @@ my @Fields = (
selectable => 'yes',
defaultselected => 'yes',
},
+ { name => 'tries_per_correct',
+ title => 'tries/correct',
+ align => 'right',
+ color => '#FFDDDD',
+ format => '%4.1f',
+ sortable => 'yes',
+ graphable => 'yes',
+ long_title => 'Tries per Correct Answer',
+ selectable => 'yes',
+ defaultselected => 'yes',
+ },
{ name => 'num_wrong',
title => '#Wrng',
align => 'right',
@@ -238,6 +251,17 @@ my @Fields = (
format => '%4.1f',
sortable => 'yes',
graphable => 'yes',
+ long_title => 'Number of students whose final answer is wrong',
+ selectable => 'yes',
+ defaultselected => 'yes',
+ },
+ { name => 'per_wrong',
+ title => '%Wrng',
+ align => 'right',
+ color => '#FFDDDD',
+ format => '%4.1f',
+ sortable => 'yes',
+ graphable => 'yes',
long_title => 'Percent of students whose final answer is wrong',
selectable => 'yes',
defaultselected => 'yes',
@@ -263,7 +287,7 @@ my @Fields = (
graphable => 'yes',
long_title => 'Degree of Discrimination',
selectable => 'yes',
- defaultselected => 'no',
+ defaultselected => 'yes',
},
## duedate included for research purposes. Commented out most of the time.
# { name => 'duedate',
@@ -309,6 +333,40 @@ my @Fields = (
# selectable => 'no',
# defaultselected => 'yes',
# },
+## maxtries included for research purposes. Commented out most of the time.
+# { name => 'maxtries',
+# title => 'Maxtries',
+# align => 'left',
+# color => '#FFFFFF',
+# sortable => 'no',
+# graphable => 'no',
+# long_title => 'Maximum number of tries',
+# selectable => 'no',
+# defaultselected => 'yes',
+# },
+## hinttries included for research purposes. Commented out most of the time.
+# { name => 'hinttries',
+# title => 'hinttries',
+# align => 'left',
+# color => '#FFFFFF',
+# sortable => 'no',
+# graphable => 'no',
+# long_title => 'Number of tries before a hint appears',
+# selectable => 'no',
+# defaultselected => 'yes',
+# },
+#
+## problem weight for instructor
+ { name => 'weight',
+ title => 'weight',
+ align => 'right',
+ color => '#FFFFFF',
+ sortable => 'no',
+ graphable => 'no',
+ long_title => 'Problem weight (for instructor)',
+ selectable => 'yes',
+ defaultselected => 'yes',
+ },
);
my @SeqFields = (
@@ -317,7 +375,7 @@ my @SeqFields = (
align => 'left',
color => '#FFFFE6',
special => 'no',
- sortable => 'no',
+ sortable => 'no',
selectable => 'yes',
defaultselected => 'no',
},
@@ -452,7 +510,7 @@ my @SeqFields = (
long_title => 'KR-21 reliability statistic',
selectable => 'yes',
defaultselected => 'no',
- },
+ },
);
my %SelectedFields;
@@ -460,35 +518,35 @@ my %SelectedFields;
sub parse_field_selection {
#
# Pull out the defaults
- if (! defined($ENV{'form.fieldselections'})) {
- $ENV{'form.fieldselections'} = [];
+ if (! defined($env{'form.fieldselections'})) {
+ $env{'form.fieldselections'} = [];
foreach my $field (@Fields) {
next if ($field->{'selectable'} ne 'yes');
if ($field->{'defaultselected'} eq 'yes') {
- push(@{$ENV{'form.fieldselections'}},$field->{'name'});
+ push(@{$env{'form.fieldselections'}},$field->{'name'});
}
}
}
#
# Make sure the data we are plotting is there
my %NeededFields;
- if (exists($ENV{'form.plot'}) && $ENV{'form.plot'} ne '' &&
- $ENV{'form.plot'} ne 'none') {
- if ($ENV{'form.plot'} eq 'degrees') {
+ if (exists($env{'form.plot'}) && $env{'form.plot'} ne '' &&
+ $env{'form.plot'} ne 'none') {
+ if ($env{'form.plot'} eq 'degrees') {
$NeededFields{'deg_of_diff'}++;
$NeededFields{'deg_of_disc'}++;
- } elsif ($ENV{'form.plot'} eq 'tries statistics') {
+ } elsif ($env{'form.plot'} eq 'tries statistics') {
$NeededFields{'mean_tries'}++;
$NeededFields{'std_tries'}++;
$NeededFields{'problem_num'}++;
} else {
- $NeededFields{$ENV{'form.plot'}}++;
+ $NeededFields{$env{'form.plot'}}++;
}
}
#
# This should not happen, but in case it does...
- if (ref($ENV{'form.fieldselections'}) ne 'ARRAY') {
- $ENV{'form.fieldselections'} = [$ENV{'form.fieldselections'}];
+ if (ref($env{'form.fieldselections'}) ne 'ARRAY') {
+ $env{'form.fieldselections'} = [$env{'form.fieldselections'}];
}
#
# Set the field data and the selected fields (for easier checking)
@@ -503,7 +561,7 @@ sub parse_field_selection {
$field->{'selected'} = 'yes';
$SelectedFields{$field->{'name'}}++;
}
- foreach my $selection (@{$ENV{'form.fieldselections'}}) {
+ foreach my $selection (@{$env{'form.fieldselections'}}) {
if ($selection eq $field->{'name'} || $selection eq 'all') {
$field->{'selected'} = 'yes';
$SelectedFields{$field->{'name'}}++;
@@ -519,7 +577,7 @@ sub parse_field_selection {
}
sub field_selection_input {
- my $Str = '
';
$Str .= '';
- $Str .= ' 'x5;
- $Str .= 'Plot '.&plot_dropdown().(' 'x10);
- $Str .= '';
- $Str .= ' 'x5;
- $Str .= '';
- $Str .= ' 'x5;
- $Str .= '';
- $Str .= ' 'x5;
+ $Str .= (' 'x10);
+ #
return $Str;
}
@@ -611,12 +672,23 @@ Main interface to problem statistics.
###############################################
###############################################
+my $navmap;
+my @sequences;
+
+sub clean_up {
+ undef($navmap);
+ undef(@sequences);
+}
+
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
+ undef($navmap);
+ undef(@sequences);
#
my %Saveable_Parameters = ('Status' => 'scalar',
'statsoutputmode' => 'scalar',
'Section' => 'array',
+ 'Groups' => 'array',
'StudentData' => 'array',
'Maps' => 'array',
'fieldselections'=> 'array');
@@ -632,28 +704,30 @@ sub BuildProblemStatisticsPage {
undef(%SeqStat);
#
# Finally let the user know we are here
- my $interface = &CreateInterface();
+ my $interface = &CreateInterface($r);
$r->print($interface);
- $r->print('');
#
- if (! exists($ENV{'form.statsfirstcall'})) {
- $r->print('');
- $r->print('
'.
+ my @CacheButtonHTML =
+ &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
+ my $Str;
+ foreach my $html (@CacheButtonHTML) {
+ $Str.=$html.(' 'x5);
+ }
+ #
+ $r->print($Str);
+ if (! exists($env{'form.firstrun'})) {
+ $r->print('
'.
&mt('Press "Generate Statistics" when you are ready.').
- '
'.
+ '
'.
+ '
'.
&mt('It may take some time to update the student data '.
- 'for the first analysis. Future analysis this session '.
- ' will not have this delay.').
+ 'for the first analysis. Future analysis this session '.
+ 'will not have this delay.').
'
');
+ &clean_up();
return;
- } elsif ($ENV{'form.statsfirstcall'} eq 'yes' ||
- exists($ENV{'form.UpdateCache'}) ||
- exists($ENV{'form.ClearCache'}) ) {
- $r->print('');
- &Apache::lonstatistics::Gather_Student_Data($r);
- } else {
- $r->print('');
}
$r->rflush();
#
@@ -661,12 +735,31 @@ sub BuildProblemStatisticsPage {
# it does not slow things down noticably.
&Apache::loncoursedata::populate_weight_table();
#
- if (exists($ENV{'form.Excel'})) {
+ ($navmap,@sequences) =
+ &Apache::lonstatistics::selected_sequences_with_assessments();
+ if (! ref($navmap)) {
+ $r->print('
');
$r->print(&sequence_html_header());
- foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+ foreach my $seq (@sequences) {
last if ($c->aborted);
- next if ($seq->{'num_assess'} < 1);
&compute_sequence_statistics($seq);
$r->print(&sequence_html_output($seq));
}
@@ -731,10 +826,9 @@ sub output_html_by_sequence {
my $c = $r->connection();
$r->print(&html_preamble());
#
- foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+ foreach my $seq (@sequences) {
last if ($c->aborted);
- next if ($seq->{'num_assess'} < 1);
- $r->print("
".$seq->{'title'}."
".
+ $r->print("
".$seq->compTitle."
".
'
'."\n".
'
'."\n".
'
'.
@@ -755,7 +849,7 @@ sub output_html_stats {
my ($r)=@_;
&compute_all_statistics($r);
$r->print(&html_preamble());
- &sort_data($ENV{'form.sortby'});
+ &sort_data($env{'form.sortby'});
#
my $count=0;
foreach my $data (@StatsArray) {
@@ -777,7 +871,7 @@ sub output_html_stats {
sub html_preamble {
my $Str='';
$Str .= "