[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemstatistics.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Mon, 29 Mar 2004 15:58:34 -0000
matthew Mon Mar 29 10:58:34 2004 EDT
Modified files:
/loncom/interface/statistics lonproblemstatistics.pm
Log:
Added "Mean and S.D. of Tries" plot.
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.73 loncom/interface/statistics/lonproblemstatistics.pm:1.74
--- loncom/interface/statistics/lonproblemstatistics.pm:1.73 Fri Mar 26 17:04:22 2004
+++ loncom/interface/statistics/lonproblemstatistics.pm Mon Mar 29 10:58:33 2004
@@ -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.74 2004/03/29 15:58:33 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -480,6 +480,8 @@
&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 +638,85 @@
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 .= '<data>'.join(',',@Labels).'</data>'.$/.
+ '<data>'.join(',',@Mean).'</data>'.$/;
+ #
+ my $std_error_data .= '<data>'.join(',',@Labels).'</data>'.$/.
+ '<data>'.join(',',@Mean).'</data>'.$/.
+ '<data>'.join(',',@STD).'</data>'.$/;
+ #
+ $plot=<<"END";
+<gnuplot
+ texfont="10"
+ fgcolor="x000000"
+ plottype="Cartesian"
+ font="large"
+ grid="on"
+ align="center"
+ border="on"
+ transparent="on"
+ alttag="Sample Plot"
+ samples="100"
+ bgcolor="xffffff"
+ height="$height"
+ width="$width">
+ <title>Mean and S.D. of Tries</title>
+ <axis xmin="0" ymin="0" xmax="$xmax" ymax="$ymax" color="x000000" />
+ <xlabel>Problem Number</xlabel>
+ <curve
+ linestyle="yerrorbars"
+ name="S.D. Tries"
+ pointtype="1"
+ color="x666666">
+ $std_error_data
+ </curve>
+ <curve
+ linestyle="points"
+ name="Mean Tries"
+ pointtype="1"
+ color="xCC4444">
+ $std_data
+ </curve>
+</gnuplot>
+END
+ my $plotresult =
+ '<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/;
+ $r->print($plotresult);
+ return;
+}
+
sub plot_dropdown {
my $current = '';
#
@@ -646,7 +727,10 @@
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".'<select name="plot" size="1">';
$Str .= '<option name="none"></option>'."\n";