--- loncom/interface/statistics/lonproblemanalysis.pm 2002/08/05 20:53:38 1.4
+++ loncom/interface/statistics/lonproblemanalysis.pm 2003/10/15 21:30:51 1.39
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
-# (Publication Handler
#
-# $Id: lonproblemanalysis.pm,v 1.4 2002/08/05 20:53:38 stredwic Exp $
+
+# $Id: lonproblemanalysis.pm,v 1.39 2003/10/15 21:30:51 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,501 +25,780 @@
#
# http://www.lon-capa.org/
#
-# (Navigate problems for statistical reports
-# YEAR=2001
-# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
-# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
-# YEAR=2002
-# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
-# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
-#
-###
-package Apache::lonproblemanalysis;
+package Apache::lonproblemanalysis;
use strict;
use Apache::lonnet();
-use GDBM_File;
-
-#my $jr;
+use Apache::loncommon();
+use Apache::lonhtmlcommon();
+use Apache::loncoursedata();
+use Apache::lonstatistics;
+use Apache::lonlocal;
+use HTML::Entities();
+
+my $plotcolors = [qw/
+ #33ff00
+ #0033cc #990000 #aaaa66 #663399 #ff9933
+ #66ccff #ff9999 #cccc33 #660000 #33cc66
+ /];
+ #[qw/lgreen dgreen dred/];
sub BuildProblemAnalysisPage {
- my ($cacheDB, $r)=@_;
-
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- $r->print('
Unable to tie database.');
- return;
+ my ($r,$c)=@_;
+ $r->print(''.&mt('Option Response Problem Analysis').'
');
+ $r->print(&CreateInterface());
+ #
+ my @Students = @Apache::lonstatistics::Students;
+ #
+ if (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->print(&IntervalOptions($cache{'Interval'}));
$r->rflush();
- $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache));
-
- untie(%cache);
-
- return;
-}
-
-sub BuildAnalyzePage {
- my ($cacheDB, $students, $courseID,$r)=@_;
-
-# $jr = $r;
- my $c = $r->connection;
-
- my $Str = '';
- my %cache;
- &Create_PrgWin($r);
- my $count=0;
- foreach (@$students) {
- &Update_PrgWin(scalar(@$students),$count,$_,$r);
- if($c->aborted) {
- return $Str;
- }
- my $downloadTime='';
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- $downloadTime = $cache{$_.':lastDownloadTime'};
- untie(%cache);
- }
- if($downloadTime eq 'Not downloaded') {
- my $courseData =
- &Apache::loncoursedata::DownloadCourseInformation($_,
- $courseID);
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
- &Apache::loncoursedata::ProcessStudentData(\%cache,
- $courseData, $_);
- untie(%cache);
+ if (exists($ENV{'form.problemchoice'}) &&
+ ! exists($ENV{'form.SelectAnother'})) {
+ $r->print('');
+ $r->print(' 'x5);
+ $r->print('');
+ $r->print(' 'x5);
+ $r->print('');
+ $r->print(' 'x5);
+ $r->print('');
+ $r->print('');
+ $r->print(' 'x5);
+ #
+ $r->print('
');
+ #
+ my ($symb,$part,$resid) = &get_problem_symb(
+ &Apache::lonnet::unescape($ENV{'form.problemchoice'})
+ );
+ #
+ my $resource = &get_resource_from_symb($symb);
+ if (defined($resource)) {
+ 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/<\s*form\s*/)|<\/nop>|g;
+ $r->print(''.
+ ''.
+ $rendered_problem.
+ ' |
');
+ ##
+ ## Analyze the problem
+ my $PerformanceData =
+ &Apache::loncoursedata::get_optionresponse_data
+ (\@Students,$symb,$resid);
+ if (defined($PerformanceData) &&
+ ref($PerformanceData) eq 'ARRAY') {
+ if ($ENV{'form.AnalyzeOver'} eq 'Tries') {
+ my $analysis_html = &tries_analysis($PerformanceData,
+ $ORdata);
+ $r->print($analysis_html);
+ } elsif ($ENV{'form.AnalyzeOver'} eq 'Time') {
+ my $analysis_html = &time_analysis($PerformanceData,
+ $ORdata);
+ $r->print($analysis_html);
+ } else {
+ $r->print(''.
+ &mt('The analysis you have selected is '.
+ 'not supported at this time').
+ '
');
+ }
} else {
- next;
+ $r->print(''.
+ &mt('There is no student data for this problem.').
+ '
');
}
+ } else {
+ $r->print('resource is undefined');
}
- $count++;
- }
- &Close_PrgWin($r);
-
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- $Str .= 'Unable to tie database.';
- return $Str;
- }
-
- my ($problemId, $part, $responseId)=split(':',$cache{'AnalyzeInfo'});
- my $uri = $cache{$problemId.':source'};
- my $problem = $cache{$problemId.':problem'};
- my $title = $cache{$problemId.':title'};
- my $interval = $cache{'Interval'};
-
- my %ConceptData;
- $ConceptData{"Interval"} = $interval;
-
- #Initialize the option response true answers
- my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
- $students->[0], $courseID);
- if(defined($analyzeData->{'error'})) {
- $Str .= 'Incorrect part requested.
';
- return $Str;
- }
-
- if($c->aborted()) { untie(%cache); return $Str; }
-
- #compute the intervals
- &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
- \%ConceptData);
-
- $title =~ s/\ /"_"/eg;
- $Str .= '
'.$uri.'';
-
- if($c->aborted()) { untie(%cache); return $Str; }
-
- #Java script Progress window
-# &Create_PrgWin();
-# &Update_PrgWin("Starting-to-analyze-problem");
- for(my $index=0; $index<(scalar @$students); $index++) {
- if($c->aborted()) { untie(%cache); return $Str; }
-# &Update_PrgWin($index);
-# &OpStatus($problem, $students->[$index], $courseID, \%ConceptData,
-# $analyzeData->{'foil_to_concept'}, $analyzeData, \%cache);
- &OpStatus($problem, $students->[$index], \%ConceptData,
- $analyzeData->{'foil_to_concept'}, $analyzeData, \%cache);
- }
-# &Close_PrgWin();
-
- $Str .= '
';
- for (my $k=0; $k<$interval; $k++ ) {
- if($c->aborted()) { untie(%cache); return $Str; }
- $Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
- \%ConceptData);
- }
- for (my $k=0; $k<$interval; $k++ ) {
- if($c->aborted()) { untie(%cache); return $Str; }
- $Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
- }
- my $Answ=&Apache::lonnet::ssi($uri);
- $Str .= '
Here you can see the Problem:
'.$Answ;
-
- untie(%cache);
-
- return $Str.'