--- loncom/interface/statistics/lonproblemanalysis.pm 2004/09/28 20:41:58 1.88
+++ loncom/interface/statistics/lonproblemanalysis.pm 2004/10/29 15:27:39 1.97
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.88 2004/09/28 20:41:58 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.97 2004/10/29 15:27:39 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,7 +56,6 @@ my @SubmitButtons = ({ name => 'PrevProb
{ name => 'ExcelOutput',
text => 'Produce Excel Output' });
-
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
#
@@ -87,7 +86,7 @@ sub BuildProblemAnalysisPage {
# Support for numerical and radio response isn't complete enough to
# include in 1.2 release.
# my $problem_types = '(option|radiobutton|numerical)';
- my $problem_types = '(option)';
+ my $problem_types = '.';#(option)';
if (exists($ENV{'form.problemchoice'}) &&
! exists($ENV{'form.SelectAnother'})) {
foreach my $button (@SubmitButtons) {
@@ -135,7 +134,9 @@ sub BuildProblemAnalysisPage {
my $resource = $current_problem->{'resource'};
$r->print('
'.$resource->{'title'}.'
');
$r->print('
'.$resource->{'src'}.'
');
- $r->print(&Apache::lonstathelpers::render_resource($resource));
+ if ($ENV{'form.show_prob'} eq 'true') {
+ $r->print(&Apache::lonstathelpers::render_resource($resource));
+ }
$r->rflush();
my %Data = &Apache::lonstathelpers::get_problem_data
($resource->{'src'});
@@ -147,9 +148,9 @@ sub BuildProblemAnalysisPage {
$problem_data,
\@Students);
} elsif ($current_problem->{'resptype'} eq 'radiobutton') {
- &RadioResponseAnalysis($r,$current_problem,
- $problem_data,
- \@Students);
+ &radio_response_analysis($r,$current_problem,
+ $problem_data,
+ \@Students);
} elsif ($current_problem->{'resptype'} eq 'numerical') {
##
## analyze all responses of a problem at once
@@ -221,10 +222,9 @@ sub NumericalResponseAnalysis {
}
#
# This next call causes all the waiting around that people complain about
- my ($max,$min) =
- &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students,
- 'Statistics',
- 'stats_status');
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students,
+ 'Statistics',
+ 'stats_status');
return if ($c->aborted());
#
# Collate the data
@@ -375,176 +375,405 @@ sub build_student_data_worksheet {
##
#########################################################
#########################################################
-sub RadioResponseAnalysis {
- my ($r,$problem,$problem_data,$Students) = @_;
- my ($resource,$respid) = ($problem->{'resource'},
- $problem->{'respid'});
+sub radio_response_analysis {
+ my ($r,$problem,$problem_analysis,$students) = @_;
+ #
+ if ($ENV{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
+ $r->print('Bad request');
+ }
+ #
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ #
my $analysis_html;
- my $PerformanceData = &Apache::loncoursedata::get_response_data
+ my $foildata = $problem_analysis->{'_Foils'};
+ my ($table,$foils,$concepts) = &build_foil_index($problem_analysis);
+ #
+ my $num_true = 0;
+ foreach my $foil (@$foils) {
+ if ($foildata->{$foil}->{'value'} eq 'true') {
+ $num_true++;
+ }
+ }
+ #
+ $analysis_html .= $table;
+ # Gather student data
+ my $response_data = &Apache::loncoursedata::get_response_data
(\@Apache::lonstatistics::SelectedSections,
$Apache::lonstatistics::enrollment_status,
$resource->{'symb'},$respid);
- if (! defined($PerformanceData) ||
- ref($PerformanceData) ne 'ARRAY' ) {
+ my $correct; # either a hash reference or a scalar
+ if ($problem_analysis->{'answercomputed'} || scalar(@$concepts) > 1) {
+ # This takes a while for large classes...
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$students,
+ 'Statistics',
+ 'stats_status');
+ foreach my $student (@$students) {
+ my ($idx,@remainder) = split('&',$student->{'answer'});
+ my ($answer) = ($remainder[$idx]=~/^(.*)=([^=]*)$/);
+ $correct->{$student->{'username'}.':'.$student->{'domain'}}=
+ &Apache::lonnet::unescape($answer);
+ }
+ } else {
+ foreach my $foil (keys(%$foildata)) {
+ if ($foildata->{$foil}->{'value'} eq 'true') {
+ $correct = $foildata->{$foil}->{'name'};
+ }
+ }
+ }
+ #
+ if (! defined($response_data) || ref($response_data) ne 'ARRAY' ) {
$analysis_html = '
'.
&mt('There is no submission data for this resource').
'