# The LearningOnline Network with CAPA # (Publication Handler # # $Id: lonproblemstatistics.pm,v 1.26 2002/08/14 17:45:19 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # 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,7/25,7/29,8/5 Behrouz Minaei # ### package Apache::lonproblemstatistics; use strict; use Apache::lonnet(); use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; my $jr; sub InitializeProblemStatistics { my ($cacheDB, $students, $courseID, $c, $r)=@_; my %cache; $jr = $r; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('Unable to tie database.'); return ('ERROR', undef); } # 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 { if($value eq $_) { $found = 1; last; } } } if($found == 0) { splice(@$students, $studentIndex, 1); } } # my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID); my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ? $cache{'StatisticsLastStatus'} : 'Nothing'; my $whichStudents = join(':::',sort(@$students)); if(!defined($cache{'StatisticsCached'}) || $lastStatus ne $cache{'Status'} || $whichStudents ne $cache{'StatisticsWhichStudents'}) { if(defined($cache{'StatisticsCached'})) { untie(%cache); unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { $r->print('Unable to tie database.'); return ('ERROR', undef); } 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 ('ERROR', undef); } unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('Unable to tie database.'); return ('ERROR', undef); } 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 ('ERROR', undef); } foreach(keys(%$problemData)) { $cache{$_} = $problemData->{$_}; } $cache{'StatisticsKeys'} = join(':::', keys(%$problemData)); $cache{'StatisticsCached'} = 'true'; $cache{'StatisticsLastStatus'} = $cache{'Status'}; $cache{'StatisticsWhichStudents'} = $whichStudents; untie(%cache); unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('Unable to tie database.'); return ('ERROR', undef); } } my $orderedProblems = &SortProblems(\%cache, $cache{'ProblemStatisticsSort'}, $cache{'SortProblems'}, $cache{'ProblemStatisticsAscend'}); return ('OK', $orderedProblems); } sub BuildProblemStatisticsPage { my ($cacheDB, $students, $courseID, $c, $r)=@_; 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 %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('Unable to tie database.'); return; } my $Ptr = ''; $Ptr .= '
Select Map | '."\n"; $Ptr .= ''; $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics', 'Statistics'); $Ptr .= ' |
Sorting Type: | '."\n"; $Ptr .= ''."\n"; $Ptr .= &Apache::lonhtmlcommon::AscendOrderOptions( $cache{'ProblemStatisticsAscend'}, 'ProblemStatistics', 'Statistics'); $Ptr .= ' |
Select Sections'; $Ptr .= ' | '."\n"; $Ptr .= ''."\n"; my @sections = split(':',$cache{'sectionList'}); my @sectionsSelected = split(':',$cache{'sectionsSelected'}); $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, \@sectionsSelected, 'Statistics'); $Ptr .= ' |