--- loncom/interface/statistics/lonproblemstatistics.pm 2004/03/26 22:04:22 1.73
+++ loncom/interface/statistics/lonproblemstatistics.pm 2004/03/29 18:22:28 1.75
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.73 2004/03/26 22:04:22 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.75 2004/03/29 18:22:28 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -310,18 +310,34 @@ sub BuildProblemStatisticsPage {
# This probably does not need to be done each time we are called, but
# it does not slow things down noticably.
&Apache::loncoursedata::populate_weight_table();
+ #
if (exists($ENV{'form.Excel'})) {
&Excel_output($r);
} else {
+ my $count = 0;
+ foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+ $count += $seq->{'num_assess'};
+ }
+ if ($count > 10) {
+ $r->print('
'.
+ &mt('Compiling statistics for [_1] problems',$count).
+ '
');
+ if ($count > 30) {
+ $r->print('
'.&mt('This will take some time.').'
');
+ }
+ $r->rflush();
+ }
+ #
my $sortby = $ENV{'form.sortby'};
$sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);
my $plot = $ENV{'form.plot'};
- &Apache::lonnet::logthis('form.plot = '.$plot);
+ if ($plot eq '' || $plot eq 'none') {
+ undef($plot);
+ }
if ($sortby eq 'container' && ! defined($plot)) {
&output_html_by_sequence($r);
} else {
if (defined($plot)) {
- &Apache::lonnet::logthis('calling plot routine');
&make_plot($r,$plot);
}
&output_html_stats($r);
@@ -385,7 +401,6 @@ sub output_html_stats {
return;
}
-
sub html_preamble {
my $Str='';
$Str .= "
".
@@ -480,6 +495,8 @@ sub make_plot {
&sort_data($ENV{'form.sortby'});
if ($plot eq 'degrees') {
°rees_plot($r);
+ } elsif ($plot eq 'tries statistics') {
+ &tries_data_plot($r);
} else {
&make_single_stat_plot($r,$plot);
}
@@ -636,6 +653,85 @@ END
return;
}
+sub tries_data_plot {
+ my ($r)=@_;
+ my $count = scalar(@StatsArray);
+ my $width = 50 + 10*$count;
+ $width = 300 if ($width < 300);
+ my $height = 300;
+ my $plot = '';
+ my @STD; my @Mean; my @Max; my @Min;
+ my @Labels;
+ my $ymax = 5;
+ foreach my $data (@StatsArray) {
+ my $max = $data->{'mean_tries'} + $data->{'std_tries'};
+ $ymax = $max if ($ymax < $max);
+ $ymax = $max if ($ymax < $max);
+ push(@Labels,$data->{'problem_num'});
+ push(@STD,$data->{'std_tries'});
+ push(@Mean,$data->{'mean_tries'});
+ }
+ #
+ # Make sure we show relevant information.
+ my $xmax = $Labels[-1];
+ if ($xmax > 50) {
+ if ($xmax % 10 != 0) {
+ $xmax = 10 * (int($xmax/10)+1);
+ }
+ } else {
+ if ($xmax % 5 != 0) {
+ $xmax = 5 * (int($xmax/5)+1);
+ }
+ }
+ $ymax = int($ymax)+1+2;
+ #
+ my $std_data .= ''.join(',',@Labels).''.$/.
+ ''.join(',',@Mean).''.$/;
+ #
+ my $std_error_data .= ''.join(',',@Labels).''.$/.
+ ''.join(',',@Mean).''.$/.
+ ''.join(',',@STD).''.$/;
+ #
+ $plot=<<"END";
+
+ Mean and S.D. of Tries
+
+ Problem Number
+
+ $std_error_data
+
+
+ $std_data
+
+
+END
+ my $plotresult =
+ '
'.&Apache::lonxml::xmlparse($r,'web',$plot).'
'.$/;
+ $r->print($plotresult);
+ return;
+}
+
sub plot_dropdown {
my $current = '';
#
@@ -646,7 +742,10 @@ sub plot_dropdown {
my @Additional_Plots = (
{ graphable=>'yes',
name => 'degrees',
- title => 'DoDisc and DoDiff' });
+ title => 'DoDisc and DoDiff' },
+ { graphable=>'yes',
+ name => 'tries statistics',
+ title => 'Mean and S.D. of Tries' });
#
my $Str= "\n".'