--- loncom/interface/statistics/lonproblemanalysis.pm 2004/11/10 21:23:10 1.104
+++ loncom/interface/statistics/lonproblemanalysis.pm 2006/02/04 19:06:53 1.124
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.104 2004/11/10 21:23:10 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.124 2006/02/04 19:06:53 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,7 +27,7 @@
package Apache::lonproblemanalysis;
use strict;
-use Apache::lonnet();
+use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
@@ -37,7 +37,7 @@ use Apache::lonstathelpers();
use Apache::lonstudentsubmissions();
use HTML::Entities();
use Time::Local();
-use Spreadsheet::WriteExcel();
+use capa;
my $plotcolors = ['#33ff00',
'#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
@@ -52,9 +52,7 @@ my @SubmitButtons = ({ name => 'PrevProb
text => 'Next Problem' },
{ name => 'break'},
{ name => 'SelectAnother',
- text => 'Choose a different Problem' },
- { name => 'ExcelOutput',
- text => 'Produce Excel Output' });
+ text => 'Choose a different Problem' });
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
@@ -75,7 +73,7 @@ sub BuildProblemAnalysisPage {
#
my @Students = @Apache::lonstatistics::Students;
#
- if (@Students < 1 && exists($ENV{'form.firstrun'})) {
+ if (@Students < 1 && exists($env{'form.firstrun'})) {
$r->print('
There are no students in the sections selected
');
}
#
@@ -83,12 +81,9 @@ sub BuildProblemAnalysisPage {
&Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
$r->rflush();
#
- # 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)';
- if (exists($ENV{'form.problemchoice'}) &&
- ! exists($ENV{'form.SelectAnother'})) {
+ my $problem_types = '(option|radiobutton|numerical)';
+ if (exists($env{'form.problemchoice'}) &&
+ ! exists($env{'form.SelectAnother'})) {
foreach my $button (@SubmitButtons) {
if ($button->{'name'} eq 'break') {
$r->print(" \n");
@@ -102,44 +97,51 @@ sub BuildProblemAnalysisPage {
$r->print($html.(' 'x5));
}
#
+
+ # 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();
#
# Determine which problem we are to analyze
my $current_problem = &Apache::lonstathelpers::get_target_from_id
- ($ENV{'form.problemchoice'});
+ ($env{'form.problemchoice'});
#
- my ($prev,$curr,$next) =
+ my ($navmap,$prev,$curr,$next) =
&Apache::lonstathelpers::get_prev_curr_next($current_problem,
$problem_types,
'response',
);
- if (exists($ENV{'form.PrevProblemAnalysis'}) && defined($prev)) {
+ if (exists($env{'form.PrevProblemAnalysis'}) && defined($prev)) {
$current_problem = $prev;
- } elsif (exists($ENV{'form.NextProblemAnalysis'}) && defined($next)) {
+ } elsif (exists($env{'form.NextProblemAnalysis'}) && defined($next)) {
$current_problem = $next;
} else {
$current_problem = $curr;
}
#
# Store the current problem choice and send it out in the form
- $ENV{'form.problemchoice'} =
+ $env{'form.problemchoice'} =
&Apache::lonstathelpers::make_target_id($current_problem);
$r->print('');
+ $env{'form.problemchoice'}.'" />');
#
if (! defined($current_problem->{'resource'})) {
$r->print('resource is undefined');
} else {
my $resource = $current_problem->{'resource'};
- $r->print('
'.$resource->{'title'}.'
');
- $r->print('
'.$resource->{'src'}.'
');
- if ($ENV{'form.show_prob'} eq 'true') {
+ $r->print('
');
+ 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'});
+ ($resource->src);
my $problem_data = $Data{$current_problem->{'part'}.
'.'.
$current_problem->{'respid'}};
@@ -160,12 +162,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::ProblemSelector
- ($problem_types));
+ $r->print(&Apache::lonstathelpers::problem_selector($problem_types,
+ $submit_button));
}
}
@@ -180,7 +184,7 @@ sub numerical_response_analysis {
my ($r,$problem,$problem_analysis,$students) = @_;
my $c = $r->connection();
#
- if ($ENV{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
+ if ($env{'form.AnalyzeOver'} !~ /^(tries|time)$/) {
$r->print('Bad request');
}
#
@@ -189,9 +193,9 @@ sub numerical_response_analysis {
$problem->{'respid'});
# Gather student data
my $response_data = &Apache::loncoursedata::get_response_data
- (\@Apache::lonstatistics::SelectedSections,
+ ([&Apache::lonstatistics::get_selected_sections()],
$Apache::lonstatistics::enrollment_status,
- $resource->{'symb'},$respid);
+ $resource->symb,$respid);
#
$problem_analysis->{'answercomputed'} = 1;
if ($problem_analysis->{'answercomputed'}) {
@@ -201,15 +205,22 @@ sub numerical_response_analysis {
'stats_status');
$r->print(&numerical_one_dimensional_plot($r,600,150,$answers));
}
+ #
+ 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++) {
+ 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') {
+ if ($env{'form.AnalyzeOver'} eq 'tries') {
$restriction_function = sub {($_[0]->{'tries'} == $plot_num?1:0)};
$header_message = 'Attempt [_1]';
$stats_message =
@@ -253,15 +264,15 @@ sub numerical_response_analysis {
$no_data_message = 'No data for [_2] to [_3]';
}
#
- my ($correct,$intervals,$answers) =
- &numerical_response_determine_intervals($r,$resource,$partid,
- $respid,$students);
+ 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) {
+ my ($responses,$stats) =
+ &numerical_classify_responses($response_data,$correct,
+ $restriction_function);
+ if ($stats->{'submission_count'} == 0) {
$analysis_html.=
'
'.
&mt($no_data_message,$plot_num,@extra_data).
@@ -273,16 +284,16 @@ sub numerical_response_analysis {
'