--- loncom/interface/statistics/lonproblemanalysis.pm 2003/10/10 13:35:43 1.29
+++ loncom/interface/statistics/lonproblemanalysis.pm 2004/01/30 16:31:36 1.63
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.29 2003/10/10 13:35:43 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.63 2004/01/30 16:31:36 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -24,7 +24,6 @@
#
# http://www.lon-capa.org/
#
-
package Apache::lonproblemanalysis;
use strict;
@@ -34,234 +33,1360 @@ use Apache::lonhtmlcommon();
use Apache::loncoursedata();
use Apache::lonstatistics;
use Apache::lonlocal;
+use Apache::lonstathelpers;
+use HTML::Entities();
+use Time::Local();
+use Spreadsheet::WriteExcel();
+
+my $plotcolors = ['#33ff00',
+ '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
+ '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66',
+ ];
+
+my @SubmitButtons = ({ name => 'PrevProblemAnalysis',
+ text => 'Previous Problem' },
+ { name => 'ProblemAnalysis',
+ text => 'Analyze Problem Again' },
+ { name => 'NextProblemAnalysis',
+ text => 'Next Problem' },
+ { name => 'break'},
+ { name => 'ClearCache',
+ text => 'Clear Caches' },
+ { name => 'updatecaches',
+ text => 'Update Student Data' },
+ { name => 'SelectAnother',
+ text => 'Choose a different Problem' },
+ { name => 'ExcelOutput',
+ text => 'Produce Excel Output' });
+
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
- $r->print('
'.&mt('Option Response Problem Analysis').'
');
+ #
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'Section' => 'array',
+ 'NumPlots' => 'scalar',
+ 'AnalyzeAs' => 'scalar',
+ 'AnalyzeOver' => 'scalar',
+ );
+ &Apache::loncommon::store_course_settings('problem_analysis',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('problem_analysis',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
+ #
+ $r->print(''.&mt('Detailed Problem Analysis').'
');
$r->print(&CreateInterface());
#
my @Students = @Apache::lonstatistics::Students;
#
- if (exists($ENV{'form.problemchoice'})) {
- $r->print('
');
+ if (@Students < 1) {
+ $r->print('There are no students in the sections selected
');
+ }
+ #
+ &Apache::loncoursedata::clear_internal_caches();
+ if (exists($ENV{'form.ClearCache'}) ||
+ exists($ENV{'form.updatecaches'}) ||
+ (exists($ENV{'form.firstanalysis'}) &&
+ $ENV{'form.firstanalysis'} ne 'no')) {
&Apache::lonstatistics::Gather_Full_Student_Data($r);
+ }
+ if (! exists($ENV{'form.firstanalysis'})) {
+ $r->print('');
+ } else {
+ $r->print('');
+ }
+ $r->rflush();
+ #
+ if (exists($ENV{'form.problemchoice'}) &&
+ ! exists($ENV{'form.SelectAnother'})) {
+ foreach my $button (@SubmitButtons) {
+ if ($button->{'name'} eq 'break') {
+ $r->print("
\n");
+ } else {
+ $r->print('{'text'}).'" />');
+ $r->print(' 'x5);
+ }
+ }
#
- my ($symb,$part,$resid) = &get_problem_symb(
- &Apache::lonnet::unescape($ENV{'form.problemchoice'})
- );
+ $r->print('
');
+ $r->rflush();
+ #
+ # Determine which problem we are to analyze
+ my $current_problem = &Apache::lonstathelpers::get_target_from_id
+ ($ENV{'form.problemchoice'});
+ #
+ my ($prev,$curr,$next) =
+ &Apache::lonstathelpers::get_prev_curr_next($current_problem,
+ '(option|radiobutton)',
+ 'response',
+ );
+ if (exists($ENV{'form.PrevProblemAnalysis'}) && defined($prev)) {
+ $current_problem = $prev;
+ } elsif (exists($ENV{'form.NextProblemAnalysis'}) && defined($next)) {
+ $current_problem = $next;
+ } else {
+ $current_problem = $curr;
+ }
#
-# my ($firsttime,$lasttime) =
-# &Apache::loncoursedata::get_timestamp_data($symb,$resid);
+ # Store the current problem choice and send it out in the form
+ $ENV{'form.problemchoice'} =
+ &Apache::lonstathelpers::make_target_id($current_problem);
+ $r->print('');
#
- my $resource = &get_resource_from_symb($symb);
- if (defined($resource)) {
+ if (! defined($current_problem->{'resource'})) {
+ $r->print('resource is undefined');
+ } else {
+ my $resource = $current_problem->{'resource'};
+ $r->print(''.$resource->{'title'}.'
');
+ $r->print(''.$resource->{'src'}.'
');
+ $r->print(&Apache::lonstathelpers::render_resource($resource));
+ $r->rflush();
my %Data = &get_problem_data($resource->{'src'});
- my $ORdata = $Data{$part.'.'.$resid};
- ##
- ## Render the problem
- my $base;
- ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
- $base = "http://".$ENV{'SERVER_NAME'}.$base;
- my $rendered_problem =
- &Apache::lonnet::ssi_body($resource->{'src'});
- $rendered_problem =~ s/