--- loncom/interface/statistics/lonproblemanalysis.pm 2002/08/01 20:49:06 1.3
+++ loncom/interface/statistics/lonproblemanalysis.pm 2002/11/25 18:17:36 1.16
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemanalysis.pm,v 1.3 2002/08/01 20:49:06 stredwic Exp $
+# $Id: lonproblemanalysis.pm,v 1.16 2002/11/25 18:17:36 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,39 +26,51 @@
# 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;
+ $r->print('Unable to tie database.');
+ return;
}
- $Str .= &IntervalOptions($cache{'Interval'});
- $Str .= &OptionResponseTable($cache{'OptionResponses'}, \%cache);
+ 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 {
@@ -69,91 +81,137 @@ sub BuildAnalyzePage {
my $Str = '';
my %cache;
- foreach (@$students) {
- 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);
+
+ 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'});
+
+ my $studentCount = scalar @$students;
+ for(my $studentIndex=$studentCount-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 {
- next;
+ if($value eq $_) {
+ $found = 1;
+ last;
+ }
}
}
+ if($found == 0) {
+ splice(@$students, $studentIndex, 1);
+ }
}
+ unless(untie(%cache)) {
+ $r->print('Can not untie hash.');
+ $r->rflush();
+ }
+
+ &Apache::lonhtmlcommon::Close_PrgWin($r);
+
+### jason code for checing is there data in cache
+# 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.';
- return $Str;
+ $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 $problem = $cache{$problemId.':problem'};
my $title = $cache{$problemId.':title'};
my $interval = $cache{'Interval'};
+ my $heading = 'Restore this particular Option Response Problem '.
+ 'Results, Please wait...';
my %ConceptData;
$ConceptData{"Interval"} = $interval;
#Initialize the option response true answers
- my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
+ my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
$students->[0], $courseID);
if(defined($analyzeData->{'error'})) {
- $Str .= 'Incorrect part requested.
';
- return $Str;
+ $Str .= $analyzeData->{'error'}.'
Incorrect part requested.
';
+ $r->print($Str);
+ return;
}
- if($c->aborted()) { untie(%cache); return $Str; }
+ $r->print($Str);
+ $Str = '';
+ if($c->aborted()) { untie(%cache); return; }
#compute the intervals
- &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
+ &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
\%ConceptData);
$title =~ s/\ /"_"/eg;
$Str .= '
'.$uri.'';
- if($c->aborted()) { untie(%cache); return $Str; }
-
+ $r->print($Str);
+ $Str = '';
+ if($c->aborted()) { untie(%cache); return; }
+
+ &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
+
+ my $count=0;
#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);
+ if($c->aborted()) { untie(%cache); return; }
+ $count++;
+ my $displayString = $count.'/'.$studentCount.': '.$_;
+ &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
+ &OpStatus($problemId, $students->[$index], \%ConceptData,
+ $analyzeData->{'foil_to_concept'}, $analyzeData,
+ \%cache, $courseID);
}
-# &Close_PrgWin();
+ &Apache::lonhtmlcommon::Close_PrgWin($r);
$Str .= '
';
for (my $k=0; $k<$interval; $k++ ) {
if($c->aborted()) { untie(%cache); return $Str; }
- $Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
+ $Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
\%ConceptData);
+ $r->print($Str);
+ $Str = '';
}
for (my $k=0; $k<$interval; $k++ ) {
if($c->aborted()) { untie(%cache); return $Str; }
$Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
+ $r->print($Str);
+ $Str = '';
}
my $Answ=&Apache::lonnet::ssi($uri);
$Str .= '
Here you can see the Problem:
'.$Answ;
+ $Str .= '