--- loncom/interface/statistics/lonproblemanalysis.pm 2006/08/17 21:19:47 1.127 +++ loncom/interface/statistics/lonproblemanalysis.pm 2008/10/23 09:07:51 1.131 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemanalysis.pm,v 1.127 2006/08/17 21:19:47 raeburn Exp $ +# $Id: lonproblemanalysis.pm,v 1.131 2008/10/23 09:07:51 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,25 +144,27 @@ sub BuildProblemAnalysisPage { $r->print(&Apache::lonstathelpers::render_resource($resource)); } $r->rflush(); - my %Data = &Apache::lonstathelpers::get_problem_data - ($resource->src); - my $problem_data = $Data{$current_problem->{'part'}. - '.'. - $current_problem->{'respid'}}; - if ($current_problem->{'resptype'} eq 'option') { - &OptionResponseAnalysis($r,$current_problem, - $problem_data, - \@Students); - } elsif ($current_problem->{'resptype'} eq 'radiobutton') { - &radio_response_analysis($r,$current_problem, - $problem_data, - \@Students); - } elsif ($current_problem->{'resptype'} eq 'numerical') { - &numerical_response_analysis($r,$current_problem, - $problem_data,\@Students); - } else { - $r->print('

Analysis of '.$current_problem->{'resptype'}.' is not supported

'); - } + if (@Students) { + my %Data = &Apache::lonstathelpers::get_problem_data + ($resource->src); + my $problem_data = $Data{$current_problem->{'part'}. + '.'. + $current_problem->{'respid'}}; + if ($current_problem->{'resptype'} eq 'option') { + &OptionResponseAnalysis($r,$current_problem, + $problem_data, + \@Students); + } elsif ($current_problem->{'resptype'} eq 'radiobutton') { + &radio_response_analysis($r,$current_problem, + $problem_data, + \@Students); + } elsif ($current_problem->{'resptype'} eq 'numerical') { + &numerical_response_analysis($r,$current_problem, + $problem_data,\@Students); + } else { + $r->print('

Analysis of '.$current_problem->{'resptype'}.' is not supported

'); + } + } } $r->print('
'); } else { @@ -327,11 +329,14 @@ sub numerical_plot_percent { last; } } + $percent_spread = $highest_percent - $lowest_percent; my $bin_size = 1; foreach (qw/0.01 0.05 0.1 0.5 1 2 5 10 20 25 50 100/) { if ($lowest_percent/2 < $_){ $bin_size = $_; - last; + if ( ($percent_spread/$bin_size) < $max_bins ) { + last; + } } } my @bins; @@ -406,6 +411,10 @@ sub numerical_plot_differences { } elsif ($low_bin < 0 && $high_bin < -$low_bin) { $high_bin = -$low_bin; } + if ($high_bin == $low_bin) { + $high_bin+=1; + $low_bin-=1; + } if (!$min_bin_size || ($high_bin -$low_bin)/$min_bin_size * 2 > $max_bins) { $min_bin_size = abs($high_bin - $low_bin) / $max_bins * 2; @@ -627,11 +636,21 @@ sub numerical_determine_answers { $sdom); # make the key my $key = $partid.'.'.$respid; + # pick one of the possible answers + my $which = 'INTERNAL'; + if (!exists($analysis->{$key}{$which})) { + $which = (sort(keys(%{ $analysis->{$key} })))[0]; + } foreach my $item ('answer','unit','ans_high','ans_low') { - $correct->{$sname.':'.$sdom}->{$item} = - $analysis->{$key.'.'.$item}->[0]; + if (ref($analysis->{$key.'.'.$item}) eq 'ARRAY') { + $correct->{$sname.':'.$sdom}->{$item} = + $analysis->{$key.'.'.$item}[0]; + } else { + $correct->{$sname.':'.$sdom}->{$item} = + $analysis->{$key.'.'.$item}{$which}[0][0]; + } } - $answers{$analysis->{$key.'.answer'}->[0]}++; + $answers{$correct->{$sname.':'.$sdom}{'answer'}}++; &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, &mt('last student')); } @@ -1835,7 +1854,7 @@ sub CreateInterface { $Str .= ''; $Str .= ''.&mt('Sections').''; $Str .= ''.&mt('Groups').''; - $Str .= ''.&mt('Enrollment Status').''; + $Str .= ''.&mt('Access Status').''; $Str .= ' '; $Str .= ''."\n"; ## @@ -1899,11 +1918,11 @@ sub CreateInterface { $Str .= ''; ## - $Str .= ''; + $Str .= ''; $Str .= ''; ## ##