--- loncom/interface/statistics/lonproblemanalysis.pm 2002/08/13 14:44:33 1.6 +++ loncom/interface/statistics/lonproblemanalysis.pm 2002/08/14 20:42:49 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonproblemanalysis.pm,v 1.6 2002/08/13 14:44:33 stredwic Exp $ +# $Id: lonproblemanalysis.pm,v 1.8 2002/08/14 20:42:49 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,6 +39,7 @@ package Apache::lonproblemanalysis; use strict; use Apache::lonnet(); +use Apache::lonhtmlcommon(); use GDBM_File; my $jr; @@ -48,11 +49,26 @@ sub BuildProblemAnalysisPage { my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { - $r->print('Unable to tie database.'); + $r->print('Unable to tie database.'); return; } - $r->print(&IntervalOptions($cache{'Interval'})); + my $Ptr = ''; + $Ptr .= ''; + $Ptr .= ''."\n"; + $Ptr .= ''."\n"; + $Ptr .= ''."\n"; + $Ptr .= '
Select Sections'; + $Ptr .= ''."\n"; + my @sectionsSelected = split(':',$cache{'sectionsSelected'}); + my @sections = split(':',$cache{'sectionList'}); + $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, + \@sectionsSelected, + 'Statistics'); + $Ptr .= '
Intervals'; + $Ptr .= &IntervalOptions($cache{'Interval'}); + $Ptr .= '

'; + $r->print($Ptr); $r->rflush(); $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache)); @@ -69,17 +85,53 @@ sub BuildAnalyzePage { my $Str = ''; my %cache; - if(&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, 'true', - $cacheDB, 'true', - 'true', $courseID, - $r, $c) ne 'OK') { + + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $Str .= 'Unable to tie database.'; + $r->print($Str); + return; + } + + # 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); + } + } + untie(%cache); + + if(&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, + 'true', + $cacheDB, + 'true', + 'true', + $courseID, + $r, + $c) ne 'OK') { $r->print($Str); return; } unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { - $Str .= 'Unable to tie database.'; + $Str .= 'Unable to tie database.'; $r->print($Str); return; } @@ -160,8 +212,7 @@ sub IntervalOptions { } } - my $Ptr = '
Select number of intervals'."\n". - ''."\n"; for(my $n=1; $n<=7;$ n++) { $Ptr .= '{$problemId.':source'}; - my $title = $cache->{$problemId.':title'}; - - my $Temp = ''.$title.''; - $Str .= ''; - $Str .= ' '.$number.' '; - $Str .= ''.$Temp.''; - $Str .= ''.$uri.''; - if($partCount{$problemId.':'.$part} < 2) { - $Str .= ''."\n"; - } else { - $Str .= ''."\n"; + my $Str = ''; + + foreach my $sequence (@orderedSequences) { + my @optionProblems = split(':::', $sequences{$sequence}); + + $Str .= ''.$cache->{$sequence.':title'}.''."\n"; + $Str .= ""; + $Str .= ''."\n"; + + my $count = 1; + foreach(@optionProblems) { + my (undef, $problemId, $part, $response)= + split(':',$sequences{$sequence}); + my $uri = $cache->{$problemId.':source'}; + my $title = $cache->{$problemId.':title'}; + + my $Temp = ''.$title.''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + if($partCount{$problemId.':'.$part} < 2) { + $Str .= ''."\n"; + } else { + my $value = $problemId.':'.$part.':'.$response; + $Str .= ''."\n"; + } + $count++; } - $number++; + $Str .= '
\# Problem Title Resource Analysis
'.$count.' '.$Temp.''.$uri.'

'."\n"; } - $Str .= ''."\n"; return $Str; }