--- loncom/interface/statistics/lonproblemanalysis.pm 2006/02/04 19:06:53 1.124
+++ loncom/interface/statistics/lonproblemanalysis.pm 2007/01/04 02:44:07 1.130
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.124 2006/02/04 19:06:53 bowersj2 Exp $
+# $Id: lonproblemanalysis.pm,v 1.130 2007/01/04 02:44:07 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,9 @@ use Apache::lonstudentsubmissions();
use HTML::Entities();
use Time::Local();
use capa;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
my $plotcolors = ['#33ff00',
'#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
@@ -59,6 +62,7 @@ sub BuildProblemAnalysisPage {
#
my %Saveable_Parameters = ('Status' => 'scalar',
'Section' => 'array',
+ 'Groups' => 'array',
'NumPlots' => 'scalar',
'AnalyzeOver' => 'scalar',
);
@@ -74,7 +78,7 @@ sub BuildProblemAnalysisPage {
my @Students = @Apache::lonstatistics::Students;
#
if (@Students < 1 && exists($env{'form.firstrun'})) {
- $r->print('
There are no students in the sections selected
');
+ $r->print('There are no students in the sections/groups selected
');
}
#
my @CacheButtonHTML =
@@ -140,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 {
@@ -194,6 +200,7 @@ sub numerical_response_analysis {
# Gather student data
my $response_data = &Apache::loncoursedata::get_response_data
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
$resource->symb,$respid);
#
@@ -322,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;
@@ -401,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;
@@ -622,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'));
}
@@ -782,6 +806,7 @@ sub radio_response_analysis {
# Gather student data
my $response_data = &Apache::loncoursedata::get_response_data
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
$resource->symb,$respid);
my $correct; # either a hash reference or a scalar
@@ -794,7 +819,7 @@ sub radio_response_analysis {
my ($idx,@remainder) = split('&',$student->{'answer'});
my ($answer) = ($remainder[$idx]=~/^(.*)=([^=]*)$/);
$correct->{$student->{'username'}.':'.$student->{'domain'}}=
- &Apache::lonnet::unescape($answer);
+ &unescape($answer);
}
} else {
foreach my $foil (keys(%$foildata)) {
@@ -1187,6 +1212,7 @@ sub OptionResponseAnalysis {
# Note: part data is not needed.
my $PerformanceData = &Apache::loncoursedata::get_response_data
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
$resource->symb,$respid);
if (! defined($PerformanceData) ||
@@ -1823,12 +1849,12 @@ sub CreateInterface {
##
## Build the menu
my $Str = '';
- $Str .= &Apache::lonhtmlcommon::breadcrumbs
- (undef,'Detailed Problem Analysis');
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Detailed Problem Analysis');
$Str .= ''."\n";
$Str .= '';
$Str .= ''.&mt('Sections').' | ';
- $Str .= ''.&mt('Enrollment Status').' | ';
+ $Str .= ''.&mt('Groups').' | ';
+ $Str .= ''.&mt('Access Status').' | ';
$Str .= ' | ';
$Str .= '
'."\n";
##
@@ -1837,6 +1863,10 @@ sub CreateInterface {
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
$Str .= '';
#
+ $Str .= ''."\n";
+ $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
+ $Str .= ' | ';
+ #
$Str .= '';
$Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
$Str .= ' | ';
@@ -1929,7 +1959,7 @@ sub hashify_attempt {
my %attempt;
$attempt{'student'} = $row->[&Apache::loncoursedata::RD_sname()];
$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{'timestamp'} = $row->[&Apache::loncoursedata::RD_timestamp()];
return %attempt;
@@ -1953,12 +1983,12 @@ sub Process_OR_Row {
my @Foilsubs = split('&',$submission);
for (my $j=0;$j<=$#Foilgrades;$j++) {
my ($foilid,$correct) = split('=',$Foilgrades[$j]);
- $foilid = &Apache::lonnet::unescape($foilid);
+ $foilid = &unescape($foilid);
my (undef,$submission) = split('=',$Foilsubs[$j]);
if ($correct) {
$RowData{$foilid}->{'_correct'}++;
} else {
- $submission = &Apache::lonnet::unescape($submission);
+ $submission = &unescape($submission);
$RowData{$foilid}->{$submission}++;
}
$RowData{$foilid}->{'_total'}++;