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

version 1.10, 2004/03/08 18:42:58 version 1.15, 2005/03/01 22:25:59
Line 39  use Apache::lonlocal; Line 39  use Apache::lonlocal;
 my @SubmitButtons = (  my @SubmitButtons = (
                      { name => 'CreatePlot',                       { name => 'CreatePlot',
                        text => 'Create Plot' },                         text => 'Create Plot' },
                      { name => 'ClearCache',  
                        text => 'Clear Caches' },  
                      { name => 'updatecaches',  
                        text => 'Update Student Data' },  
                      );                       );
   
 #########################################################  #########################################################
Line 81  sub BuildCorrectProblemsPage { Line 77  sub BuildCorrectProblemsPage {
                   '</h2>');                    '</h2>');
     }      }
     #      #
     &Apache::loncoursedata::clear_internal_caches();      my @CacheButtonHTML = 
     if (exists($ENV{'form.ClearCache'}) ||           &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
         exists($ENV{'form.updatecaches'}) ||  
         (exists($ENV{'form.firstanalysis'}) &&  
          $ENV{'form.firstanalysis'} ne 'no')) {  
         &Apache::lonstatistics::Gather_Full_Student_Data($r);  
     }  
     if (! exists($ENV{'form.firstanalysis'})) {  
         $r->print('<input type="hidden" name="firstanalysis" value="yes" />');  
     } else {  
         $r->print('<input type="hidden" name="firstanalysis" value="no" />');  
     }  
     foreach my $button (@SubmitButtons) {      foreach my $button (@SubmitButtons) {
         $r->print('<input type="submit" name="'.$button->{'name'}.'" '.          $r->print('<input type="submit" name="'.$button->{'name'}.'" '.
                   'value="'.&mt($button->{'text'}).'" />');                    'value="'.&mt($button->{'text'}).'" />');
         $r->print('&nbsp;'x5);          $r->print('&nbsp;'x5);
     }      }
       foreach my $html (@CacheButtonHTML) {
           $r->print($html.('&nbsp;'x5));
       }
     $r->rflush();      $r->rflush();
     #      #
     # Determine which problem symbs we are to sum over      # Determine which problem symbs we are to sum over
Line 105  sub BuildCorrectProblemsPage { Line 94  sub BuildCorrectProblemsPage {
         my @ProblemSymbs;          my @ProblemSymbs;
         my $total_parts = 0;          my $total_parts = 0;
         my $title = '';          my $title = '';
         if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') {          my @maps = &Apache::lonstatistics::get_selected_maps('Maps');
             foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){          my ($navmap,@sequences) =
               &Apache::lonstatistics::selected_sequences_with_assessments();
           if ($maps[0] ne 'all') {
               foreach my $seq (@sequences) {
                 if ($title eq '') {                  if ($title eq '') {
                     $title = $seq->{'title'};                      $title = $seq->compTitle;
                 } else {                  } else {
                     $title = 'Multiple Sequences';                      $title = 'Multiple Sequences';
                 }                  }
                 foreach my $res (@{$seq->{'contents'}}) {                  my @resources = 
                     next if ($res->{'type'} ne 'assessment');                      &Apache::lonstathelpers::get_resources($navmap,$seq);
                     foreach my $part (@{$res->{'parts'}}) {                  foreach my $res (@resources) {
                       foreach my $partid (@{$res->parts}) {
                         $total_parts++;                          $total_parts++;
                         push(@ProblemSymbs,{symb=>$res->{'symb'},                          push(@ProblemSymbs,{symb=>$res->symb,
                                             part=>$part});                                              part=>$partid});
                     }                      }
                 }                  }
             }              }
           } else {
               $title = "All Problems";
               foreach my $seq (@sequences) {
                   my @resources = 
                       &Apache::lonstathelpers::get_resources($navmap,$seq);
                   foreach my $res (@resources) {
                       $total_parts += scalar(@{$res->parts});
                   }
               }
         }          }
         my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();          my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
         if (defined($starttime) || defined($endtime)) {          if (defined($starttime) || defined($endtime)) {
Line 135  sub BuildCorrectProblemsPage { Line 137  sub BuildCorrectProblemsPage {
              $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_parts));
       } else {
           $r->print('<h3>'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'</h3>');
     }      }
     return;      return;
 }  }
Line 157  sub AnalyzeScoreData { Line 161  sub AnalyzeScoreData {
     my ($score_data,$title,$total_parts) = @_;      my ($score_data,$title,$total_parts) = @_;
     #      #
     # Basic check first      # Basic check first
     if (@$score_data < 1) {      if (ref($score_data) ne 'ARRAY' || @$score_data < 1) {
         return '<h2>There is no data to plot</h2>';          return '<h2>'.&mt('There is no data to plot').'</h2>';
     }      }
     #      #
     # Determine which bins to use      # Determine which bins to use
     my $lowest  = $score_data->[0]->[0];      my $lowest  = $score_data->[0]->[0];
     $lowest = 0;      $lowest = 0;
     my $highest = $score_data->[-1]->[0];      my $highest = $score_data->[-1]->[0];
     &Apache::lonnet::logthis('highest = '.$highest);  
     my $binsize = 1;      my $binsize = 1;
     if ($highest > 50) { $binsize = 2; }      if ($highest > 50) { $binsize = 2; }
     if ($highest > 100) { $binsize = 5; }      if ($highest > 100) { $binsize = 5; }
Line 177  sub AnalyzeScoreData { Line 180  sub AnalyzeScoreData {
     # Get the data into the bins (destroying $score_data in the process)      # Get the data into the bins (destroying $score_data in the process)
     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 = '<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n";      my $Str = 
           '<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)) {
         push (@Xdata,$bin->{'start'});          push (@Xdata,$bin->{'start'});
Line 193  sub AnalyzeScoreData { Line 197  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 = "<br />\n".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum,      $Str = "\n<p>".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum,
                                  'Num Correct Problems (max:'.$total_parts.')',                                   'Correct Problems (max possible = '.$total_parts.')',
                                                        'Number of students',                                                         'Number of students',
                                                        $max,                                                         $max,
                                                        undef, # colors                                                         undef, # colors
                                                        \@Xdata,                                                         \@Xdata,
                                                        \@Ydata).                                                         \@Ydata).
                                                            "\n<br />\n".$Str;                                                             "\n<br />\n".$Str;
       $Str .= '</p>'."\n";
     return $Str;                                                     return $Str;                                               
 }  }
   
Line 279  sub CreateInterface { Line 284  sub CreateInterface {
     ##      ##
     ## Environment variable initialization      ## Environment variable initialization
     my $Str;      my $Str;
     $Str .= &Apache::lonhtmlcommon::breadcrumbs      $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Correct Problems Plot');
         (undef,'Correct Problems Plot');      $Str .= '<p>';
       #
     $Str .= '<table cellspacing="5">'."\n";      $Str .= '<table cellspacing="5">'."\n";
     $Str .= '<tr>';      $Str .= '<tr>';
     $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';      $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
Line 289  sub CreateInterface { Line 295  sub CreateInterface {
     $Str .= '<td rowspan="2">'.      $Str .= '<td rowspan="2">'.
         &Apache::lonstathelpers::limit_by_time_form().'</td>';          &Apache::lonstathelpers::limit_by_time_form().'</td>';
     $Str .= '</tr>'."\n";      $Str .= '</tr>'."\n";
     ##      #
     ##   
     $Str .= '<tr><td align="center">'."\n";      $Str .= '<tr><td align="center">'."\n";
     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);      $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
     $Str .= '</td>';      $Str .= '</td>';
Line 299  sub CreateInterface { Line 304  sub CreateInterface {
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);      $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
     #      #
     my $only_seq_with_assessments = sub {       $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
         my $s=shift;  
         if ($s->{'num_assess'} < 1) {   
             return 0;  
         } else {   
             return 1;  
         }  
     };  
     $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,  
                                               $only_seq_with_assessments);  
     $Str .= '</td>';      $Str .= '</td>';
     #      #
     ##  
     $Str .= '</tr>'."\n";      $Str .= '</tr>'."\n";
     $Str .= '</table>'."\n";      $Str .= '</table>'."\n";
       #
       $Str .= '<nobr>'.&mt('Status: [_1]',
                            '<input type="text" '.
                            'name="stats_status" size="60" value="" />').
               '</nobr>'.'</p>';
       ##
     return $Str;      return $Str;
 }  }
   

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


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