Diff for /loncom/interface/statistics/lonproblemanalysis.pm between versions 1.124 and 1.129

version 1.124, 2006/02/04 19:06:53 version 1.129, 2006/12/21 19:52:28
Line 38  use Apache::lonstudentsubmissions(); Line 38  use Apache::lonstudentsubmissions();
 use HTML::Entities();  use HTML::Entities();
 use Time::Local();  use Time::Local();
 use capa;  use capa;
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
     
   
 my $plotcolors = ['#33ff00',   my $plotcolors = ['#33ff00', 
                   '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',                    '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
Line 59  sub BuildProblemAnalysisPage { Line 62  sub BuildProblemAnalysisPage {
     #      #
     my %Saveable_Parameters = ('Status' => 'scalar',      my %Saveable_Parameters = ('Status' => 'scalar',
                                'Section' => 'array',                                 'Section' => 'array',
                                  'Groups' => 'array',
                                'NumPlots' => 'scalar',                                 'NumPlots' => 'scalar',
                                'AnalyzeOver' => 'scalar',                                 'AnalyzeOver' => 'scalar',
                                );                                 );
Line 74  sub BuildProblemAnalysisPage { Line 78  sub BuildProblemAnalysisPage {
     my @Students = @Apache::lonstatistics::Students;      my @Students = @Apache::lonstatistics::Students;
     #      #
     if (@Students < 1 && exists($env{'form.firstrun'})) {      if (@Students < 1 && exists($env{'form.firstrun'})) {
         $r->print('<h2>There are no students in the sections selected</h2>');          $r->print('<h2>There are no students in the sections/groups selected</h2>');
     }      }
     #      #
     my @CacheButtonHTML =       my @CacheButtonHTML = 
Line 140  sub BuildProblemAnalysisPage { Line 144  sub BuildProblemAnalysisPage {
                 $r->print(&Apache::lonstathelpers::render_resource($resource));                  $r->print(&Apache::lonstathelpers::render_resource($resource));
             }              }
             $r->rflush();              $r->rflush();
             my %Data = &Apache::lonstathelpers::get_problem_data      if (@Students) {
                 ($resource->src);   my %Data = &Apache::lonstathelpers::get_problem_data
             my $problem_data = $Data{$current_problem->{'part'}.      ($resource->src);
                                     '.'.   my $problem_data = $Data{$current_problem->{'part'}.
                                     $current_problem->{'respid'}};       '.'.
             if ($current_problem->{'resptype'} eq 'option') {       $current_problem->{'respid'}};
                 &OptionResponseAnalysis($r,$current_problem,   if ($current_problem->{'resptype'} eq 'option') {
                                         $problem_data,      &OptionResponseAnalysis($r,$current_problem,
                                         \@Students);      $problem_data,
             } elsif ($current_problem->{'resptype'} eq 'radiobutton') {      \@Students);
                 &radio_response_analysis($r,$current_problem,   } elsif ($current_problem->{'resptype'} eq 'radiobutton') {
                                          $problem_data,      &radio_response_analysis($r,$current_problem,
                                          \@Students);       $problem_data,
             } elsif ($current_problem->{'resptype'} eq 'numerical') {       \@Students);
                 &numerical_response_analysis($r,$current_problem,   } elsif ($current_problem->{'resptype'} eq 'numerical') {
                                              $problem_data,\@Students);      &numerical_response_analysis($r,$current_problem,
             } else {   $problem_data,\@Students);
                 $r->print('<h2>Analysis of '.$current_problem->{'resptype'}.' is not supported</h2>');   } else {
             }      $r->print('<h2>Analysis of '.$current_problem->{'resptype'}.' is not supported</h2>');
    }
       }
         }          }
         $r->print('<hr />');          $r->print('<hr />');
     } else {      } else {
Line 194  sub numerical_response_analysis { Line 200  sub numerical_response_analysis {
     # Gather student data      # Gather student data
     my $response_data = &Apache::loncoursedata::get_response_data      my $response_data = &Apache::loncoursedata::get_response_data
         ([&Apache::lonstatistics::get_selected_sections()],          ([&Apache::lonstatistics::get_selected_sections()],
            [&Apache::lonstatistics::get_selected_groups()],
          $Apache::lonstatistics::enrollment_status,           $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);           $resource->symb,$respid);
     #      #
Line 322  sub numerical_plot_percent { Line 329  sub numerical_plot_percent {
             last;              last;
         }          }
     }      }
       $percent_spread = $highest_percent - $lowest_percent;
     my $bin_size = 1;      my $bin_size = 1;
     foreach (qw/0.01 0.05 0.1 0.5 1 2 5 10 20 25 50 100/) {      foreach (qw/0.01 0.05 0.1 0.5 1 2 5 10 20 25 50 100/) {
         if ($lowest_percent/2 < $_){          if ($lowest_percent/2 < $_){
             $bin_size = $_;              $bin_size = $_;
             last;      if ( ($percent_spread/$bin_size) < $max_bins ) {
    last;
       }
         }          }
     }      }
     my @bins;      my @bins;
Line 401  sub numerical_plot_differences { Line 411  sub numerical_plot_differences {
     } elsif ($low_bin < 0 && $high_bin < -$low_bin) {      } elsif ($low_bin < 0 && $high_bin < -$low_bin) {
         $high_bin = -$low_bin;          $high_bin = -$low_bin;
     }      }
       if ($high_bin == $low_bin) {
    $high_bin+=1;
    $low_bin-=1;
       }
     if (!$min_bin_size ||      if (!$min_bin_size ||
         ($high_bin -$low_bin)/$min_bin_size * 2 > $max_bins) {          ($high_bin -$low_bin)/$min_bin_size * 2 > $max_bins) {
         $min_bin_size = abs($high_bin - $low_bin) / $max_bins * 2;          $min_bin_size = abs($high_bin - $low_bin) / $max_bins * 2;
Line 782  sub radio_response_analysis { Line 796  sub radio_response_analysis {
     # Gather student data      # Gather student data
     my $response_data = &Apache::loncoursedata::get_response_data      my $response_data = &Apache::loncoursedata::get_response_data
         ([&Apache::lonstatistics::get_selected_sections()],          ([&Apache::lonstatistics::get_selected_sections()],
            [&Apache::lonstatistics::get_selected_groups()],
          $Apache::lonstatistics::enrollment_status,           $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);           $resource->symb,$respid);
     my $correct;   # either a hash reference or a scalar      my $correct;   # either a hash reference or a scalar
Line 794  sub radio_response_analysis { Line 809  sub radio_response_analysis {
             my ($idx,@remainder) = split('&',$student->{'answer'});              my ($idx,@remainder) = split('&',$student->{'answer'});
             my ($answer) = ($remainder[$idx]=~/^(.*)=([^=]*)$/);              my ($answer) = ($remainder[$idx]=~/^(.*)=([^=]*)$/);
             $correct->{$student->{'username'}.':'.$student->{'domain'}}=              $correct->{$student->{'username'}.':'.$student->{'domain'}}=
                 &Apache::lonnet::unescape($answer);                  &unescape($answer);
         }          }
     } else {      } else {
         foreach my $foil (keys(%$foildata)) {          foreach my $foil (keys(%$foildata)) {
Line 1187  sub OptionResponseAnalysis { Line 1202  sub OptionResponseAnalysis {
     # Note: part data is not needed.      # Note: part data is not needed.
     my $PerformanceData = &Apache::loncoursedata::get_response_data      my $PerformanceData = &Apache::loncoursedata::get_response_data
         ([&Apache::lonstatistics::get_selected_sections()],          ([&Apache::lonstatistics::get_selected_sections()],
            [&Apache::lonstatistics::get_selected_groups()],
          $Apache::lonstatistics::enrollment_status,           $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);           $resource->symb,$respid);
     if (! defined($PerformanceData) ||       if (! defined($PerformanceData) || 
Line 1823  sub CreateInterface { Line 1839  sub CreateInterface {
     ##      ##
     ## Build the menu      ## Build the menu
     my $Str = '';      my $Str = '';
     $Str .= &Apache::lonhtmlcommon::breadcrumbs      $Str .= &Apache::lonhtmlcommon::breadcrumbs('Detailed Problem Analysis');
         (undef,'Detailed Problem Analysis');  
     $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>';
     $Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';      $Str .= '<td align="center"><b>'.&mt('Groups').'</b></td>';
       $Str .= '<td align="center"><b>'.&mt('Access Status').'</b></td>';
     $Str .= '<td align="center">&nbsp;</td>';      $Str .= '<td align="center">&nbsp;</td>';
     $Str .= '</tr>'."\n";      $Str .= '</tr>'."\n";
     ##      ##
Line 1837  sub CreateInterface { Line 1853  sub CreateInterface {
     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);      $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
     $Str .= '</td>';      $Str .= '</td>';
     #      #
       $Str .= '<td align="center">'."\n";
       $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
       $Str .= '</td>';
       #
     $Str .= '<td align="center">';      $Str .= '<td align="center">';
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);      $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td>';      $Str .= '</td>';
Line 1929  sub hashify_attempt { Line 1949  sub hashify_attempt {
     my %attempt;      my %attempt;
     $attempt{'student'}    = $row->[&Apache::loncoursedata::RD_sname()];      $attempt{'student'}    = $row->[&Apache::loncoursedata::RD_sname()];
     $attempt{'tries'}      = $row->[&Apache::loncoursedata::RD_tries()];      $attempt{'tries'}      = $row->[&Apache::loncoursedata::RD_tries()];
     $attempt{'submission'} = &Apache::lonnet::unescape($row->[&Apache::loncoursedata::RD_submission()]);      $attempt{'submission'} = &unescape($row->[&Apache::loncoursedata::RD_submission()]);
     $attempt{'award'}      = $row->[&Apache::loncoursedata::RD_awarddetail()];      $attempt{'award'}      = $row->[&Apache::loncoursedata::RD_awarddetail()];
     $attempt{'timestamp'}  = $row->[&Apache::loncoursedata::RD_timestamp()];      $attempt{'timestamp'}  = $row->[&Apache::loncoursedata::RD_timestamp()];
     return %attempt;      return %attempt;
Line 1953  sub Process_OR_Row { Line 1973  sub Process_OR_Row {
     my @Foilsubs   = split('&',$submission);      my @Foilsubs   = split('&',$submission);
     for (my $j=0;$j<=$#Foilgrades;$j++) {      for (my $j=0;$j<=$#Foilgrades;$j++) {
         my ($foilid,$correct)  = split('=',$Foilgrades[$j]);          my ($foilid,$correct)  = split('=',$Foilgrades[$j]);
         $foilid = &Apache::lonnet::unescape($foilid);          $foilid = &unescape($foilid);
         my (undef,$submission) = split('=',$Foilsubs[$j]);          my (undef,$submission) = split('=',$Foilsubs[$j]);
         if ($correct) {          if ($correct) {
             $RowData{$foilid}->{'_correct'}++;              $RowData{$foilid}->{'_correct'}++;
         } else {          } else {
             $submission = &Apache::lonnet::unescape($submission);              $submission = &unescape($submission);
             $RowData{$foilid}->{$submission}++;              $RowData{$foilid}->{$submission}++;
         }          }
         $RowData{$foilid}->{'_total'}++;          $RowData{$foilid}->{'_total'}++;

Removed from v.1.124  
changed lines
  Added in v.1.129


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