--- loncom/interface/statistics/lonproblemanalysis.pm 2004/09/28 20:45:40 1.89
+++ loncom/interface/statistics/lonproblemanalysis.pm 2004/12/03 21:53:59 1.107
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.89 2004/09/28 20:45:40 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.107 2004/12/03 21:53:59 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,7 @@ use Apache::lonstudentsubmissions();
use HTML::Entities();
use Time::Local();
use Spreadsheet::WriteExcel();
+use capa;
my $plotcolors = ['#33ff00',
'#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
@@ -56,7 +57,6 @@ my @SubmitButtons = ({ name => 'PrevProb
{ name => 'ExcelOutput',
text => 'Produce Excel Output' });
-
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
#
@@ -86,8 +86,8 @@ 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|radiobutton|numerical)';
+ # my $problem_types = '.';#(option)';
if (exists($ENV{'form.problemchoice'}) &&
! exists($ENV{'form.SelectAnother'})) {
foreach my $button (@SubmitButtons) {
@@ -135,7 +135,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,23 +149,14 @@ 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
- my $res = $current_problem->{'resource'};
- foreach my $partid (@{$res->{'parts'}}) {
- $current_problem->{'part'} = $partid;
- foreach my $respid (@{$res->{'partdata'}->{$partid}->{'ResponseIds'}}) {
- $current_problem->{'respid'}=$respid;
- &NumericalResponseAnalysis($r,$current_problem,
- $problem_data,\@Students);
- }
- }
+ &numerical_response_analysis($r,$current_problem,
+ $problem_data,\@Students);
} else {
- $r->print('
This analysis is not supported
');
+ $r->print('
Analysis of '.$current_problem->{'resptype'}.' is not supported
');
}
}
$r->print('');
@@ -177,7 +170,6 @@ sub BuildProblemAnalysisPage {
}
}
-
#########################################################
#########################################################
##
@@ -185,80 +177,432 @@ sub BuildProblemAnalysisPage {
##
#########################################################
#########################################################
-sub NumericalResponseAnalysis {
- my ($r,$problem,$problem_data,$Students) = @_;
+sub numerical_response_analysis {
+ my ($r,$problem,$problem_analysis,$students) = @_;
my $c = $r->connection();
- my ($resource,$partid,$respid) = ($problem->{'resource'},
- $problem->{'part'},
- $problem->{'respid'});
#
- if (scalar(@{$resource->{'parts'}})>1) {
- if (@{$resource->{'partdata'}->{$partid}->{'ResponseIds'}}>1) {
- $r->print('
');
+ if ($ENV{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
+ $r->print('Bad request');
}
#
- my $analysis_html;
- my $PerformanceData = &Apache::loncoursedata::get_response_data
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ # 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' ) {
- $analysis_html = '
'.
- &mt('There is no submission data for this resource').
- '
';
- $r->print($analysis_html);
- return;
+ #
+ $problem_analysis->{'answercomputed'} = 1;
+ if ($problem_analysis->{'answercomputed'}) {
+ my $answers =
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$students,
+ 'Statistics',
+ 'stats_status');
+ $r->print(&numerical_one_dimensional_plot($r,600,150,$answers));
}
#
- # This next call causes all the waiting around that people complain about
- my ($max,$min) =
- &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students,
- 'Statistics',
- 'stats_status');
- return if ($c->aborted());
+ if (ref($response_data) ne 'ARRAY') {
+ $r->print('
'.
+ &mt('There is no submission data for this resource').
+ '
');
+ return;
+ }
+ my $analysis_html = '
';
+ for (my $plot_num = 1;$plot_num<=$ENV{'form.NumPlots'};$plot_num++) {
+ my $restriction_function;
+ my $header_message;
+ my $stats_message;
+ my $post_message; # passed through &mt sooner rather than later
+ my $no_data_message;
+ my @extra_data;
+ if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+ $restriction_function = sub {($_[0]->{'tries'} == $plot_num?1:0)};
+ $header_message = 'Attempt [_1]';
+ $stats_message =
+ '[_1] submissions, [_2] correct, [_3] incorrect';
+ $post_message = '';
+ $no_data_message = 'No data exists for attempt [_1]';
+ } else {
+ my $starttime = &Apache::lonhtmlcommon::get_date_from_form
+ ('startdate_'.$plot_num);
+ my $endtime = &Apache::lonhtmlcommon::get_date_from_form
+ ('enddate_'.$plot_num);
+ ($starttime,$endtime) = &ensure_start_end_times
+ ($starttime,$endtime,
+ &get_time_from_row($response_data->[0]),
+ &get_time_from_row($response_data->[-1]),
+ $plot_num);
+ $header_message = 'Data from [_2] to [_3]';
+ $extra_data[0] = &Apache::lonlocal::locallocaltime($starttime);
+ $extra_data[1] = &Apache::lonlocal::locallocaltime($endtime);
+ #
+ $stats_message =
+ '[_1] submissions from [_4] students, [_2] correct, [_3] incorrect';
+ #
+ $post_message =
+ &mt('Start time: [_1]',
+ &Apache::lonhtmlcommon::date_setter
+ ('Statistics','startdate_'.$plot_num,$starttime)).
+ ' '.
+ &mt('End time: [_1]',
+ &Apache::lonhtmlcommon::date_setter
+ ('Statistics','enddate_'.$plot_num,$endtime));
+ $restriction_function =
+ sub {
+ my $t = $_[0]->{'timestamp'};
+ if ($t >= $starttime && $t < $endtime) {
+ return 1;
+ } else {
+ return 0;
+ }
+ };
+ $no_data_message = 'No data for [_2] to [_3]';
+ }
+ #
+ my ($correct,$answers) =
+ &numerical_determine_answers($r,$resource,$partid,
+ $respid,$students);
+ if ($c->aborted()) { return; };
+ #
+ my $responses = &numerical_classify_responses($response_data,$correct,
+ $restriction_function);
+ if ($responses->{'_count'} == 0) {
+ $analysis_html.=
+ '