--- loncom/interface/statistics/lonproblemanalysis.pm 2002/08/05 20:53:38 1.4
+++ loncom/interface/statistics/lonproblemanalysis.pm 2002/08/14 16:18:55 1.7
@@ -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.7 2002/08/14 16:18:55 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,20 +39,36 @@ package Apache::lonproblemanalysis;
use strict;
use Apache::lonnet();
+use Apache::lonhtmlcommon();
use GDBM_File;
-#my $jr;
+my $jr;
sub BuildProblemAnalysisPage {
my ($cacheDB, $r)=@_;
my %cache;
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- $r->print('
Unable to tie database.');
+ $r->print('Unable to tie database.');
return;
}
- $r->print(&IntervalOptions($cache{'Interval'}));
+ 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));
@@ -64,42 +80,60 @@ sub BuildProblemAnalysisPage {
sub BuildAnalyzePage {
my ($cacheDB, $students, $courseID,$r)=@_;
-# $jr = $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);
+
+ 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 {
- next;
+ if($value eq $_) {
+ $found = 1;
+ last;
+ }
}
}
- $count++;
+ if($found == 0) {
+ splice(@$students, $studentIndex, 1);
+ }
}
- &Close_PrgWin($r);
+ untie(%cache);
+
+ if(&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
+ 'true',
+ $cacheDB,
+ 'true',
+ 'true',
+ $courseID,
+ $r,
+ $c) ne 'OK') {
+ $r->print($Str);
+ 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'});
@@ -115,11 +149,14 @@ sub BuildAnalyzePage {
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'},
@@ -128,37 +165,39 @@ sub BuildAnalyzePage {
$title =~ s/\ /"_"/eg;
$Str .= '
'.$uri.'';
- if($c->aborted()) { untie(%cache); return $Str; }
+ $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++) {
- 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,
+ if($c->aborted()) { untie(%cache); return; }
+ &OpStatus($problemId, $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);
+ $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 .= '