--- loncom/interface/statistics/lonproblemstatistics.pm 2005/03/10 17:33:57 1.101
+++ loncom/interface/statistics/lonproblemstatistics.pm 2006/05/01 19:29:13 1.107
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.101 2005/03/10 17:33:57 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.107 2006/05/01 19:29:13 albertel 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;
@@ -516,35 +516,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)
@@ -559,7 +559,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'}}++;
@@ -608,8 +608,8 @@ sub CreateInterface {
&parse_field_selection();
#
my $Str = '';
- $Str .= &Apache::lonhtmlcommon::breadcrumbs
- (undef,'Overall Problem Statistics','Statistics_Overall_Key');
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics',
+ 'Statistics_Overall_Key');
$Str .= '
'."\n";
$Str .= '
';
$Str .= '
'.&mt('Sections').'
';
@@ -661,6 +661,11 @@ Main interface to problem statistics.
my $navmap;
my @sequences;
+sub clean_up {
+ undef($navmap);
+ undef(@sequences);
+}
+
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
undef($navmap);
@@ -686,7 +691,7 @@ sub BuildProblemStatisticsPage {
# Finally let the user know we are here
my $interface = &CreateInterface($r);
$r->print($interface);
- $r->print('');
#
my @CacheButtonHTML =
@@ -697,7 +702,7 @@ sub BuildProblemStatisticsPage {
}
#
$r->print($Str);
- if (! exists($ENV{'form.firstrun'})) {
+ if (! exists($env{'form.firstrun'})) {
$r->print('
'.
&mt('Press "Generate Statistics" when you are ready.').
'
'.
@@ -705,6 +710,7 @@ sub BuildProblemStatisticsPage {
'for the first analysis. Future analysis this session '.
' will not have this delay.').
'
');
+ &clean_up();
return;
}
$r->rflush();
@@ -718,14 +724,21 @@ sub BuildProblemStatisticsPage {
if (! ref($navmap)) {
$r->print('
'.&mt('A course-wide error occured.').'
'.
'
'.$navmap.'
');
+ &clean_up();
return;
}
- if (exists($ENV{'form.Excel'})) {
+ if (exists($env{'form.Excel'})) {
+ $r->print('