--- loncom/interface/statistics/lonproblemanalysis.pm 2002/07/24 14:52:32 1.1 +++ loncom/interface/statistics/lonproblemanalysis.pm 2002/08/05 20:53:38 1.4 @@ -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.4 2002/08/05 20:53:38 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,80 +41,124 @@ use strict; use Apache::lonnet(); 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; + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $r->print('Unable to tie database.'); + return; } - $Str .= &IntervalOptions($cache{'Interval'}); - $Str .= &OptionResponseTable($cache{'OptionResponses'}); + $r->print(&IntervalOptions($cache{'Interval'})); + $r->rflush(); + $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache)); 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)) { + &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); + } else { + next; + } + } + $count++; + } + &Close_PrgWin($r); + + 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'}, + 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 .= 'Incorrect part requested.