--- loncom/interface/statistics/lonproblemstatistics.pm 2002/08/09 19:49:30 1.17 +++ loncom/interface/statistics/lonproblemstatistics.pm 2002/08/13 12:21:46 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonproblemstatistics.pm,v 1.17 2002/08/09 19:49:30 albertel Exp $ +# $Id: lonproblemstatistics.pm,v 1.20 2002/08/13 12:21:46 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,12 +43,15 @@ use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; +my $jr; sub BuildProblemStatisticsPage { my ($cacheDB, $students, $courseID, $c, $r)=@_; my %cache; - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { + $jr = $r; + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { return '
Unable to tie database.'; } @@ -66,352 +69,79 @@ 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, $_); - untie(%cache); - } - $count++; - } - &Close_PrgWin($r); + + &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,'true', + $cacheDB,'true', + 'true',$courseID, + $r, $c); if($c->aborted()) { return; } - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { return 'Unable to tie database.'; } - 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 @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 $state=$ENV{'form.ProblemStatisticsHeading'}; - - my $TempCache; - - if ($state) { - $TempCache=&CacheStatisticsTable($state,\%cache,\%Header, - $r,$color); - } else { - my %discriminant=(); - my @list=(); - my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID); - my $index=0; - foreach (@$students) { - $index++; - &ExtractStudentData(\%cache, $_, \@list,\%Discuss, $r, - \%discriminant); - } - my ($upper, $lower) = &Discriminant(\%discriminant,$r); - $TempCache= &BuildStatisticsTable(\%cache, $upper, $lower, - \@list, \%Header, $students, - $r, $color); - } +# my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID); +# my ($upper, $lower) = &Discriminant(\%discriminant,$r); + my ($problemData) = &ExtractStudentData(\%cache, $students); + &CalculateStatistics($problemData); + &SortProblems($problemData, $cache{'ProblemStatisticsSort'}, + $cache{'ProblemStatisticsAscend'}); + #$TempCache= + &BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, + $problemData, \@Header, $r, $color); untie(%cache); - foreach (keys %$TempCache) { - last if ($c->aborted()); - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { - $cache{$_}=$TempCache->{$_}; +# foreach (keys %$TempCache) { +# last if ($c->aborted()); +# if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { +# $cache{$_}=$TempCache->{$_}; +# untie(%cache); +# } +# } - untie(%cache); - } - } - if($c->aborted()) { return; } - untie(%cache); +# if($c->aborted()) { return; } +# untie(%cache); + + return; } #---- Problem Statistics Web Page --------------------------------------- sub CreateProblemStatisticsTableHeading { - my ($displayFormat,$sequenceSource,$sequenceTitle,$headings,$r)=@_; - if($displayFormat eq 'Display CSV Format') { - $r->print('P# | '."\n"; - for(my $nIndex=0; $nIndex < (scalar (keys %$headings)); $nIndex++) { - $Result .= ''.''.' | '."\n"; - } - $Result .= "\n".'
---|
'."\n");
+ $r->print(' |