--- loncom/interface/statistics/lonproblemanalysis.pm 2005/04/07 06:56:24 1.120
+++ loncom/interface/statistics/lonproblemanalysis.pm 2006/08/17 21:19:47 1.127
@@ -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.127 2006/08/17 21:19:47 raeburn 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();
@@ -159,11 +166,14 @@ sub BuildProblemAnalysisPage {
}
$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 +198,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);
#
@@ -338,7 +349,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 +406,8 @@ 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 (!$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 +787,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 +800,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 +1193,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,11 +1830,11 @@ 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('Groups').' | ';
$Str .= ''.&mt('Enrollment Status').' | ';
$Str .= ' | ';
$Str .= '
'."\n";
@@ -1828,6 +1844,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 +1940,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 +1964,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'}++;