--- loncom/interface/statistics/lonproblemanalysis.pm 2006/08/18 15:15:38 1.128 +++ loncom/interface/statistics/lonproblemanalysis.pm 2006/12/21 19:52:28 1.129 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemanalysis.pm,v 1.128 2006/08/18 15:15:38 raeburn Exp $ +# $Id: lonproblemanalysis.pm,v 1.129 2006/12/21 19:52:28 albertel 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;