Diff for /loncom/interface/statistics/lonproblemstatistics.pm between versions 1.73 and 1.75

version 1.73, 2004/03/26 22:04:22 version 1.75, 2004/03/29 18:22:28
Line 310  sub BuildProblemStatisticsPage { Line 310  sub BuildProblemStatisticsPage {
     # This probably does not need to be done each time we are called, but      # This probably does not need to be done each time we are called, but
     # it does not slow things down noticably.      # it does not slow things down noticably.
     &Apache::loncoursedata::populate_weight_table();      &Apache::loncoursedata::populate_weight_table();
       #
     if (exists($ENV{'form.Excel'})) {      if (exists($ENV{'form.Excel'})) {
         &Excel_output($r);          &Excel_output($r);
     } else {      } else {
           my $count = 0;
           foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
               $count += $seq->{'num_assess'};
           }
           if ($count > 10) {
               $r->print('<h2>'.
                         &mt('Compiling statistics for [_1] problems',$count).
                         '</h2>');
               if ($count > 30) {
                   $r->print('<h3>'.&mt('This will take some time.').'</h3>');
               }
               $r->rflush();
           }
           #
         my $sortby = $ENV{'form.sortby'};          my $sortby = $ENV{'form.sortby'};
         $sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);          $sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);
         my $plot = $ENV{'form.plot'};          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)) {          if ($sortby eq 'container' && ! defined($plot)) {
             &output_html_by_sequence($r);              &output_html_by_sequence($r);
         } else {          } else {
             if (defined($plot)) {              if (defined($plot)) {
                 &Apache::lonnet::logthis('calling plot routine');  
                 &make_plot($r,$plot);                  &make_plot($r,$plot);
             }              }
             &output_html_stats($r);              &output_html_stats($r);
Line 385  sub output_html_stats { Line 401  sub output_html_stats {
     return;      return;
 }  }
   
   
 sub html_preamble {  sub html_preamble {
     my $Str='';      my $Str='';
     $Str .= "<h2>".      $Str .= "<h2>".
Line 480  sub make_plot { Line 495  sub make_plot {
     &sort_data($ENV{'form.sortby'});      &sort_data($ENV{'form.sortby'});
     if ($plot eq 'degrees') {      if ($plot eq 'degrees') {
         &degrees_plot($r);          &degrees_plot($r);
       } elsif ($plot eq 'tries statistics') {
           &tries_data_plot($r);
     } else {      } else {
         &make_single_stat_plot($r,$plot);          &make_single_stat_plot($r,$plot);
     }      }
Line 636  END Line 653  END
     return;      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 {  sub plot_dropdown {
     my $current = '';      my $current = '';
     #      #
Line 646  sub plot_dropdown { Line 742  sub plot_dropdown {
     my @Additional_Plots = (      my @Additional_Plots = (
                             { graphable=>'yes',                              { graphable=>'yes',
                               name => 'degrees',                                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">';      my $Str= "\n".'<select name="plot" size="1">';
     $Str .= '<option name="none"></option>'."\n";      $Str .= '<option name="none"></option>'."\n";

Removed from v.1.73  
changed lines
  Added in v.1.75


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>