version 1.27, 2002/08/14 20:42:49
|
version 1.28, 2002/08/14 21:51:51
|
Line 52 sub InitializeProblemStatistics {
|
Line 52 sub InitializeProblemStatistics {
|
$jr = $r; |
$jr = $r; |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database1.'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
|
|
Line 80 sub InitializeProblemStatistics {
|
Line 80 sub InitializeProblemStatistics {
|
} |
} |
} |
} |
|
|
|
my $isNotCached = 0; |
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ? |
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ? |
$cache{'StatisticsLastStatus'} : 'Nothing'; |
$cache{'StatisticsLastStatus'} : 'Nothing'; |
my $whichStudents = join(':::',sort(@$students)); |
my $whichStudents = join(':::',sort(@$students)); |
if(!defined($cache{'StatisticsCached'}) || |
if(!defined($cache{'StatisticsCached'}) || |
$lastStatus ne $cache{'Status'} || |
$lastStatus ne $cache{'Status'} || |
$whichStudents ne $cache{'StatisticsWhichStudents'}) { |
$whichStudents ne $cache{'StatisticsWhichStudents'}) { |
if(defined($cache{'StatisticsCached'})) { |
$isNotCached = 1; |
untie(%cache); |
} |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
|
$r->print('Unable to tie database.'); |
untie(%cache); |
return ('ERROR', undef); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
} |
$r->print('Unable to tie database.2'); |
my @statkeys = split(':::', $cache{'StatisticsKeys'}); |
return ('ERROR', undef); |
delete $cache{'StatisticsKeys'}; |
} |
delete $cache{'StatisticsCached'}; |
if($isNotCached && defined($cache{'StatisticsCached'})) { |
foreach(@statkeys) { |
my @statkeys = split(':::', $cache{'StatisticsKeys'}); |
delete $cache{$_}; |
delete $cache{'StatisticsKeys'}; |
} |
delete $cache{'StatisticsCached'}; |
|
foreach(@statkeys) { |
|
delete $cache{$_}; |
} |
} |
untie(%cache); |
} |
|
|
|
untie(%cache); |
|
if($isNotCached) { |
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, |
'true', |
'true', |
$cacheDB, |
$cacheDB, |
Line 107 sub InitializeProblemStatistics {
|
Line 113 sub InitializeProblemStatistics {
|
'true', |
'true', |
$courseID, |
$courseID, |
$r, $c); |
$r, $c); |
if($c->aborted()) { return ('ERROR', undef); } |
} |
|
if($c->aborted()) { return ('ERROR', undef); } |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.3'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
my ($problemData) = &ExtractStudentData(\%cache, $students); |
my $problemData; |
|
if($isNotCached) { |
|
($problemData) = &ExtractStudentData(\%cache, $students); |
&CalculateStatistics($problemData, \%cache); |
&CalculateStatistics($problemData, \%cache); |
untie(%cache); |
} |
|
untie(%cache); |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.4'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
} |
|
if($isNotCached) { |
foreach(keys(%$problemData)) { |
foreach(keys(%$problemData)) { |
$cache{$_} = $problemData->{$_}; |
$cache{$_} = $problemData->{$_}; |
} |
} |
Line 128 sub InitializeProblemStatistics {
|
Line 139 sub InitializeProblemStatistics {
|
$cache{'StatisticsCached'} = 'true'; |
$cache{'StatisticsCached'} = 'true'; |
$cache{'StatisticsLastStatus'} = $cache{'Status'}; |
$cache{'StatisticsLastStatus'} = $cache{'Status'}; |
$cache{'StatisticsWhichStudents'} = $whichStudents; |
$cache{'StatisticsWhichStudents'} = $whichStudents; |
untie(%cache); |
} |
|
untie(%cache); |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.5'); |
return ('ERROR', undef); |
return ('ERROR', undef); |
} |
|
} |
} |
|
|
my $orderedProblems = &SortProblems(\%cache, |
my $orderedProblems = &SortProblems(\%cache, |
$cache{'ProblemStatisticsSort'}, |
$cache{'ProblemStatisticsSort'}, |
$cache{'SortProblems'}, |
$cache{'SortProblems'}, |
$cache{'ProblemStatisticsAscend'}); |
$cache{'ProblemStatisticsAscend'}); |
|
untie(%cache); |
|
|
return ('OK', $orderedProblems); |
return ('OK', $orderedProblems); |
} |
} |
|
|
Line 153 sub BuildProblemStatisticsPage {
|
Line 166 sub BuildProblemStatisticsPage {
|
my %cache; |
my %cache; |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.6'); |
return; |
return; |
} |
} |
my $Ptr = ''; |
my $Ptr = ''; |
Line 197 sub BuildProblemStatisticsPage {
|
Line 210 sub BuildProblemStatisticsPage {
|
} |
} |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$r->print('Unable to tie database.'); |
$r->print('Unable to tie database.6'); |
return; |
return; |
} |
} |
&BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, |
&BuildStatisticsTable(\%cache, $cache{'DisplayFormat'}, |
Line 220 sub BuildGraphicChart {
|
Line 233 sub BuildGraphicChart {
|
} |
} |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
return 'Unable to tie database.'; |
return 'Unable to tie database.7'; |
} |
} |
|
|
my @problems = split(':::', $cache{'problemList'}); |
my @problems = split(':::', $cache{'problemList'}); |