Diff for /loncom/interface/statistics/loncorrectproblemplot.pm between versions 1.15 and 1.16

version 1.15, 2005/03/01 22:25:59 version 1.16, 2005/03/07 20:12:08
Line 92  sub BuildCorrectProblemsPage { Line 92  sub BuildCorrectProblemsPage {
     # Determine which problem symbs we are to sum over      # Determine which problem symbs we are to sum over
     if (exists($ENV{'form.CreatePlot'})) {      if (exists($ENV{'form.CreatePlot'})) {
         my @ProblemSymbs;          my @ProblemSymbs;
         my $total_parts = 0;          my $total_weights = 0;
         my $title = '';          my $title = '';
         my @maps = &Apache::lonstatistics::get_selected_maps('Maps');          my @maps = &Apache::lonstatistics::get_selected_maps('Maps');
         my ($navmap,@sequences) =          my ($navmap,@sequences) =
Line 104  sub BuildCorrectProblemsPage { Line 104  sub BuildCorrectProblemsPage {
                 } else {                  } else {
                     $title = 'Multiple Sequences';                      $title = 'Multiple Sequences';
                 }                  }
                 my @resources =   
                     &Apache::lonstathelpers::get_resources($navmap,$seq);  
                 foreach my $res (@resources) {  
                     foreach my $partid (@{$res->parts}) {  
                         $total_parts++;  
                         push(@ProblemSymbs,{symb=>$res->symb,  
                                             part=>$partid});  
                     }  
                 }  
             }              }
         } else {          } else {
             $title = "All Problems";              $title = 'All Problems';
             foreach my $seq (@sequences) {          }
                 my @resources =           foreach my $seq (@sequences) {
                     &Apache::lonstathelpers::get_resources($navmap,$seq);              my @resources = 
                 foreach my $res (@resources) {                  &Apache::lonstathelpers::get_resources($navmap,$seq);
                     $total_parts += scalar(@{$res->parts});              foreach my $res (@resources) {
                   foreach my $partid (@{$res->parts}) {
                       push(@ProblemSymbs,{symb=>$res->symb,
                                           part=>$partid});
                       $total_weights += 
                           &Apache::lonnet::EXT('resource.'.$partid.'.weight',
                                                $res->symb,
                                                undef,undef,undef);
                 }                  }
             }              }
         }          }
Line 131  sub BuildCorrectProblemsPage { Line 129  sub BuildCorrectProblemsPage {
                           &Apache::lonlocal::locallocaltime($starttime),                            &Apache::lonlocal::locallocaltime($starttime),
                           &Apache::lonlocal::locallocaltime($endtime)));                            &Apache::lonlocal::locallocaltime($endtime)));
         }          }
           &Apache::loncoursedata::populate_weight_table();
         my $score_data = &Apache::loncoursedata::get_student_scores          my $score_data = &Apache::loncoursedata::get_student_scores
             (\@Apache::lonstatistics::SelectedSections,              (\@Apache::lonstatistics::SelectedSections,
              \@ProblemSymbs,               \@ProblemSymbs,
              $Apache::lonstatistics::enrollment_status,undef,               $Apache::lonstatistics::enrollment_status,undef,
              $starttime,$endtime);               $starttime,$endtime);
         $r->print(&AnalyzeScoreData($score_data,$title,$total_parts));          $r->print(&AnalyzeScoreData($score_data,$title,$total_weights));
     } else {      } else {
         $r->print('<h3>'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'</h3>');          $r->print('<h3>'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'</h3>');
     }      }
Line 158  return html with a plot of the data and Line 157  return html with a plot of the data and
 #########################################################  #########################################################
 #########################################################  #########################################################
 sub AnalyzeScoreData {  sub AnalyzeScoreData {
     my ($score_data,$title,$total_parts) = @_;      my ($score_data,$title,$maximum) = @_;
     #      #
     # Basic check first      # Basic check first
     if (ref($score_data) ne 'ARRAY' || @$score_data < 1) {      if (ref($score_data) ne 'ARRAY' || @$score_data < 1) {
Line 181  sub AnalyzeScoreData { Line 180  sub AnalyzeScoreData {
     my @Bins = &bin_data($score_data,$binsize,$lowest,$highest);      my @Bins = &bin_data($score_data,$binsize,$lowest,$highest);
     my @Xdata; my @Ydata; my $max;      my @Xdata; my @Ydata; my $max;
     my $Str =       my $Str = 
           '<p>'.
           &mt('Problem weights do not reflect individual student settings.')
           .'</p>'.
         '<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n";          '<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n";
     my $sum = 0;      my $sum = 0;
     while (my $bin = shift(@Bins)) {      while (my $bin = shift(@Bins)) {
Line 197  sub AnalyzeScoreData { Line 199  sub AnalyzeScoreData {
     $max = 5*(int($max/5)+1);      $max = 5*(int($max/5)+1);
     $Str .= "</table><br />\n";      $Str .= "</table><br />\n";
     $title = &HTML::Entities::decode($title);      $title = &HTML::Entities::decode($title);
     $Str = "\n<p>".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum,      $Str = "\n<p>".
                                  'Correct Problems (max possible = '.$total_parts.')',          &Apache::loncommon::DrawBarGraph($title.' ('.$sum.' students)',
                                                        'Number of students',                                'Correct Problems (max possible = '.$maximum.')',
                                                        $max,                                           'Number of students',
                                                        undef, # colors                                           $max,undef, # colors
                                                        \@Xdata,                                           \@Xdata,\@Ydata).
                                                        \@Ydata).                                           "\n<br />\n".$Str;
                                                            "\n<br />\n".$Str;  
     $Str .= '</p>'."\n";      $Str .= '</p>'."\n";
     return $Str;                                                     return $Str;                                               
 }  }

Removed from v.1.15  
changed lines
  Added in v.1.16


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