--- loncom/interface/statistics/lonproblemstatistics.pm 2002/08/06 02:01:05 1.14 +++ loncom/interface/statistics/lonproblemstatistics.pm 2002/08/14 13:13:37 1.24 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonproblemstatistics.pm,v 1.14 2002/08/06 02:01:05 minaeibi Exp $ +# $Id: lonproblemstatistics.pm,v 1.24 2002/08/14 13:13:37 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,13 +43,17 @@ use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; +my $jr; sub BuildProblemStatisticsPage { my ($cacheDB, $students, $courseID, $c, $r)=@_; my %cache; - #my %DoDiff; - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - return '
Unable to tie database.'; + + $jr = $r; + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $r->print('Unable to tie database.'); + return; } my $Ptr = ''; @@ -66,372 +70,146 @@ sub BuildProblemStatisticsPage { 'ProblemStatistics', 'Statistics'); $Ptr .= ''."\n"; - $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'}); + $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'}, + $cache{'DisplayLegend'}); $Ptr .= ''; - $Ptr .= &ProblemStatisticsLegend(); + if($cache{'DisplayLegend'} eq 'Show Legend') { + $Ptr .= &ProblemStatisticsLegend(); + } $r->print($Ptr); $r->rflush(); - untie(%cache); - &Create_PrgWin($r); - my $count=0; - foreach (@$students) { - &Update_PrgWin(scalar(@$students),$count,$_,$r); - my $courseData = - &Apache::loncoursedata::DownloadCourseInformation($_, $courseID); - last if ($c->aborted()); - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { - &Apache::loncoursedata::ProcessStudentData(\%cache, - $courseData, $_); + my @Header = ("Homework Sets Order","#Stdnts","Tries","Mod", + "Mean","#YES","#yes","%Wrng","DoDiff", + "S.D.","Skew.","D.F.1st","D.F.2nd","Disc."); + my $color=&setbgcolor(0); + +# my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID); +# my ($upper, $lower) = &Discriminant(\%discriminant,$r); + if(!defined($cache{'StatisticsCached'})) { + if(defined($cache{'StatisticsCached'})) { untie(%cache); + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { + $r->print('Unable to tie database.'); + return; + } + my @statkeys = split(':::', $cache{'StatisticsKeys'}); + delete $cache{'StatisticsKeys'}; + delete $cache{'StatisticsCached'}; + foreach(@statkeys) { + delete $cache{$_}; + } + } + untie(%cache); + &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, + 'true', + $cacheDB, + 'true', + 'true', + $courseID, + $r, $c); + if($c->aborted()) { return; } + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $r->print('Unable to tie database.'); + return; + } + my ($problemData) = &ExtractStudentData(\%cache, $students); + &CalculateStatistics($problemData, \%cache); + untie(%cache); + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { + $r->print('Unable to tie database.'); + return; + } + foreach(keys(%$problemData)) { + $cache{$_} = $problemData->{$_}; + } + $cache{'StatisticsKeys'} = join(':::', keys(%$problemData)); + $cache{'StatisticsCached'} = 'true'; + untie(%cache); + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $r->print('Unable to tie database.'); + return; } - $count++; - } - &Close_PrgWin($r); - if($c->aborted()) { return; } - - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - return 'Unable to tie database.'; } + my $orderedProblems = &SortProblems(\%cache, + $cache{'ProblemStatisticsSort'}, + $cache{'ProblemStatisticsAscend'}); + &BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, $orderedProblems, + \@Header, $r, $color); + untie(%cache); - my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", - 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", - 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); - my $color=&setbgcolor(0); + return; +} - my $state=$ENV{'form.ProblemStatisticsHeading'}; +sub BuildGraphicChart { + my ($graph,$cacheDB,$courseDescription,$r)=@_; + my %cache; + my $max = 0; -# my $state=&Apache::lonstatistics::CheckFormElement(\%cache, -# 'ProblemStatisticsHeading', -# 'ProblemStatisticsHeading', -# 'Homework Sets Order'); -# $r->print("P# | '."\n"; - for(my $nIndex=0; $nIndex < (scalar (keys %$headings)); $nIndex++) { - $Result .= ''.''.' | '."\n"; + $title = 'Wrong-Percentage'; } - $Result .= "\n".'
---|