--- loncom/interface/statistics/lonproblemanalysis.pm 2005/04/07 06:56:24 1.120
+++ 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.120 2005/04/07 06:56:24 albertel Exp $
+# $Id: lonproblemanalysis.pm,v 1.129 2006/12/21 19:52:28 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 =
@@ -97,8 +101,11 @@ sub BuildProblemAnalysisPage {
$r->print($html.(' 'x5));
}
#
- $r->print(&Apache::lonstathelpers::submission_report_form
- ('problem_analysis'));
+
+ # This is commented out pending actual implementation of
+ # CSV and Excel output.
+ #$r->print(&Apache::lonstathelpers::submission_report_form
+ # ('problem_analysis'));
#
$r->print('
');
$r->rflush();
@@ -137,33 +144,38 @@ 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 {
- $r->print('');
+ my $submit_button = '';
+ $r->print($submit_button);
$r->print(' 'x5);
$r->print(''.&mt('Please select a problem to analyze').'
');
- $r->print(&Apache::lonstathelpers::problem_selector($problem_types));
+ $r->print(&Apache::lonstathelpers::problem_selector($problem_types,
+ $submit_button));
}
}
@@ -188,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);
#
@@ -316,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;
@@ -338,7 +354,9 @@ sub numerical_plot_percent {
while (my ($ans,$submissions) = each(%$responses)) {
while (my ($submission,$counts) = each(%$submissions)) {
my ($correct_count,$incorrect_count) = @$counts;
- my $scaled_value = 100*($submission-$ans)/abs($ans);
+ my $scaled_value =
+ ($ans) ? 100*($submission-$ans)/abs($ans)
+ : 0;
if ($scaled_value < $bins[0]) {
$bins[0]=$scaled_value -1;
}
@@ -393,7 +411,12 @@ sub numerical_plot_differences {
} elsif ($low_bin < 0 && $high_bin < -$low_bin) {
$high_bin = -$low_bin;
}
- if (($high_bin -$low_bin)/$min_bin_size * 2 > $max_bins) {
+ 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;
}
my @bins;
@@ -773,6 +796,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
@@ -785,7 +809,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)) {
@@ -1178,6 +1202,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) ||
@@ -1814,12 +1839,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";
##
@@ -1828,6 +1853,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 .= ' | ';
@@ -1920,7 +1949,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;
@@ -1944,12 +1973,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'}++;