--- loncom/interface/statistics/lonproblemanalysis.pm 2002/07/24 14:52:32 1.1
+++ loncom/interface/statistics/lonproblemanalysis.pm 2002/11/22 04:04:10 1.13
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemanalysis.pm,v 1.1 2002/07/24 14:52:32 stredwic Exp $
+# $Id: lonproblemanalysis.pm,v 1.13 2002/11/22 04:04:10 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,95 +26,179 @@
# 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
+# 5/12,7/26,9/7,11/22 Behrouz Minaei
#
###
-package Apache::lonproblemanalysis;
+package Apache::lonproblemanalysis;
use strict;
use Apache::lonnet();
+use Apache::lonhtmlcommon();
use GDBM_File;
+my $jr;
+
sub BuildProblemAnalysisPage {
- my ($cacheDB)=@_;
+ my ($cacheDB, $r)=@_;
my %cache;
- my $Str = '';
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $Str .= '
Unable to tie database.';
- return $Str;
- }
-
- $Str .= &IntervalOptions($cache{'Interval'});
- $Str .= &OptionResponseTable($cache{'OptionResponses'});
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+ $r->print('Unable to tie database.');
+ return;
+ }
+
+ my $Ptr = '';
+ $Ptr .= '';
+ $Ptr .= 'Select Sections';
+ $Ptr .= ' | '."\n";
+ $Ptr .= ''."\n";
+ my @sectionsSelected = split(':',$cache{'sectionsSelected'});
+ my @sections = split(':',$cache{'sectionList'});
+ $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
+ \@sectionsSelected,
+ 'Statistics');
+ $Ptr .= ' |
'."\n";
+ $Ptr .= 'Intervals | '."\n";
+ $Ptr .= '';
+ $Ptr .= &IntervalOptions($cache{'Interval'});
+ $Ptr .= ' |
';
+ $r->print($Ptr);
+ $r->rflush();
+ $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache, $r));
untie(%cache);
- return $Str;
+ return;
}
sub BuildAnalyzePage {
- my ($cacheDB, $students, $courseID)=@_;
+ my ($cacheDB, $students, $courseID,$r)=@_;
- my $Str = '';
+ $jr = $r;
+ my $c = $r->connection;
+
+ my $Str = '';
my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $Str .= 'Unable to tie database.';
- return $Str;
- }
- my $uri = $cache{'AnalyzeURI'},
- my $part = $cache{'AnalyzePart'},
- my $problem = $cache{'AnalyzeProblem'},
- my $title = $cache{'AnalyzeTitle'},
- my $interval = $cache{'Interval'},
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+ $Str .= 'Unable to tie database.';
+ $r->print($Str);
+ return;
+ }
+
+ # Remove students who don't have the proper section.
+ my @sectionsSelected = split(':',$cache{'sectionsSelected'});
+ for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0;
+ $studentIndex--) {
+ my $value = $cache{$students->[$studentIndex].':section'};
+ my $found = 0;
+ foreach (@sectionsSelected) {
+ if($_ eq 'none') {
+ if($value eq '' || !defined($value) || $value eq ' ') {
+ $found = 1;
+ last;
+ }
+ } else {
+ if($value eq $_) {
+ $found = 1;
+ last;
+ }
+ }
+ }
+ if($found == 0) {
+ splice(@$students, $studentIndex, 1);
+ }
+ }
+ unless(untie(%cache)) {
+ $r->print('Can not untie hash.');
+ $r->rflush();
+ }
+
+# my $error =
+# &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
+# 'true',
+# $cacheDB,
+# 'true',
+# 'true',
+# $courseID,
+# $r, $c);
+# if($error ne 'OK') {
+# $r->print($error.'
Error downloading course data
');
+# return;
+# }
+
+
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+ $Str .= 'Unable to tie database.';
+ $r->print($Str);
+ return;
+ }
+
+ 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 ($Concepts, $foil_to_concept, $answer) = &InitAnalysis($uri, $part,
- $problem,
- $students->[0],
- $courseID);
+ my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
+ $students->[0], $courseID);
+ if(defined($analyzeData->{'error'})) {
+ $Str .= $analyzeData->{'error'}.'
Incorrect part requested.
';
+ $r->print($Str);
+ return;
+ }
+
+ $r->print($Str);
+ $Str = '';
+ if($c->aborted()) { untie(%cache); return; }
#compute the intervals
- &Interval($part, $problem, $interval, $Concepts, \%ConceptData);
+ &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
+ \%ConceptData);
$title =~ s/\ /"_"/eg;
$Str .= '
'.$uri.'';
-
+
+ $r->print($Str);
+ $Str = '';
+ if($c->aborted()) { untie(%cache); return; }
+
#Java script Progress window
- &Create_PrgWin();
- &Update_PrgWin("Starting-to-analyze-problem");
- for (my $index=0;$index<(scalar @$students);$index++) {
- &Update_PrgWin($index);
- &OpStatus($problem, $students->[$index], $courseID, $answer);
+ for(my $index=0; $index<(scalar @$students); $index++) {
+ if($c->aborted()) { untie(%cache); return; }
+ &OpStatus($problemId, $students->[$index], \%ConceptData,
+ $analyzeData->{'foil_to_concept'}, $analyzeData,
+ \%cache, $courseID);
}
- &Close_PrgWin();
$Str .= '
';
for (my $k=0; $k<$interval; $k++ ) {
- $Str .= &DrawGraph($k, $title, $Concepts, \%ConceptData);
+ if($c->aborted()) { untie(%cache); return $Str; }
+ $Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
+ \%ConceptData);
+ $r->print($Str);
+ $Str = '';
}
for (my $k=0; $k<$interval; $k++ ) {
- $Str .= &DrawTable($k, $Concepts, \%ConceptData);
+ if($c->aborted()) { untie(%cache); return $Str; }
+ $Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
+ $r->print($Str);
+ $Str = '';
}
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%ConceptData);
-#$Apache::lonxml::debug=0;
my $Answ=&Apache::lonnet::ssi($uri);
$Str .= '
Here you can see the Problem:
'.$Answ;
+ $Str .= '