--- loncom/interface/statistics/lonproblemanalysis.pm 2004/06/24 18:47:36 1.87
+++ loncom/interface/statistics/lonproblemanalysis.pm 2004/10/15 16:50:30 1.94
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.87 2004/06/24 18:47:36 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.94 2004/10/15 16:50:30 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,14 +56,12 @@ my @SubmitButtons = ({ name => 'PrevProb
{ name => 'ExcelOutput',
text => 'Produce Excel Output' });
-
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
#
my %Saveable_Parameters = ('Status' => 'scalar',
'Section' => 'array',
'NumPlots' => 'scalar',
- 'AnalyzeAs' => 'scalar',
'AnalyzeOver' => 'scalar',
);
&Apache::loncommon::store_course_settings('problem_analysis',
@@ -88,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) {
@@ -136,20 +134,22 @@ 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'});
- my $ProblemData = $Data{$current_problem->{'part'}.
+ my $problem_data = $Data{$current_problem->{'part'}.
'.'.
$current_problem->{'respid'}};
if ($current_problem->{'resptype'} eq 'option') {
&OptionResponseAnalysis($r,$current_problem,
- $ProblemData,
+ $problem_data,
\@Students);
} elsif ($current_problem->{'resptype'} eq 'radiobutton') {
&RadioResponseAnalysis($r,$current_problem,
- $ProblemData,
+ $problem_data,
\@Students);
} elsif ($current_problem->{'resptype'} eq 'numerical') {
##
@@ -160,7 +160,7 @@ sub BuildProblemAnalysisPage {
foreach my $respid (@{$res->{'partdata'}->{$partid}->{'ResponseIds'}}) {
$current_problem->{'respid'}=$respid;
&NumericalResponseAnalysis($r,$current_problem,
- $ProblemData,\@Students);
+ $problem_data,\@Students);
}
}
} else {
@@ -187,7 +187,7 @@ sub BuildProblemAnalysisPage {
#########################################################
#########################################################
sub NumericalResponseAnalysis {
- my ($r,$problem,$ProblemData,$Students) = @_;
+ my ($r,$problem,$problem_data,$Students) = @_;
my $c = $r->connection();
my ($resource,$partid,$respid) = ($problem->{'resource'},
$problem->{'part'},
@@ -222,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
@@ -377,69 +376,395 @@ sub build_student_data_worksheet {
#########################################################
#########################################################
sub RadioResponseAnalysis {
- my ($r,$problem,$ProblemData,$Students) = @_;
- my ($resource,$respid) = ($problem->{'resource'},
- $problem->{'respid'});
+ my ($r,$problem,$problem_analysis,$students) = @_;
+ if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+ &RR_tries_analysis($r,$problem,$problem_analysis,$students);
+ } elsif ($ENV{'form.AnalyzeOver'} eq 'time') {
+ &RR_static_time_analysis($r,$problem,$problem_analysis,$students);
+ } else {
+ $r->print('Bad request');
+ }
+ return;
+}
+
+sub RR_computed_tries_analysis {
+ my ($r,$problem,$problem_analysis) = @_;
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ $r->print('The tries answer you seek must be computed');
+ # Gather student data
+ # for each try
+ # loop through data, classifying it by
+ # correct foil -> selected foil
+ # if there is concept data
+ # make a concept correct plot
+ # for each correct foil
+ # make a plot of the data
+}
+
+sub RR_computed_time_analysis {
+ my ($r,$problem,$problem_analysis) = @_;
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ $r->print('The time answer you seek must be computed');
+ # Gather student data
+ # for time division
+ # limit to between start time & end time
+ # loop through data, classifying it by
+ # correct foil -> selected foil
+ # if there is concept data
+ # make a concept correct plot
+ # for each correct foil
+ # make a plot of the data
+}
+
+sub RR_tries_analysis {
+ my ($r,$problem,$problem_analysis,$students) = @_;
+ 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);
+ $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'};
+ last;
+ }
+ }
+ }
+ if (! defined($response_data) ||
+ ref($response_data) ne 'ARRAY' ) {
+ $analysis_html = '
'.
+ &mt('There is no submission data for this resource').
+ '