--- loncom/interface/statistics/lonstudentassessment.pm 2002/07/26 16:22:09 1.3 +++ loncom/interface/statistics/lonstudentassessment.pm 2002/07/31 14:35:38 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstudentassessment.pm,v 1.3 2002/07/26 16:22:09 stredwic Exp $ +# $Id: lonstudentassessment.pm,v 1.5 2002/07/31 14:35:38 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,10 +42,12 @@ use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; +#my $jr; + sub BuildStudentAssessmentPage { my ($cacheDB,$students,$courseID,$formName,$headings,$spacing, $studentInformation,$r,$c)=@_; - +# $jr = $r; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { $r->print('Unable to tie database.'); @@ -75,23 +77,24 @@ sub BuildStudentAssessmentPage { splice(@$students, $studentIndex, 1); } } + my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys, + $doNotShow) = + &ShouldShowColumns(\%cache, $headings, $studentInformation); my $selectedName = &FindSelectedStudent(\%cache, $cache{'StudentAssessmentStudent'}, $students); - $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName)); + $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName, + $doNotShow)); - my $Ptr = ''; + my $Str = ''; if($selectedName eq 'No Student Selected') { - $Ptr .= '

WARNING: '; - $Ptr .= 'Please select a student

'; - $r->print($Ptr); + $Str .= '

WARNING: '; + $Str .= 'Please select a student

'; + $r->print($Str); return; } - my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys) = - &ShouldShowColumns(\%cache, $headings, $studentInformation); - $r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings, $sequenceKeys, $sequenceHeadings)); untie(%cache); @@ -103,26 +106,22 @@ sub BuildStudentAssessmentPage { $selectedName ne 'All Students'); $selected = 1; my $courseData; - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - if($cache{$_.':lastDownloadTime'} eq 'Not downloaded') { - untie(%cache); - $courseData = - &Apache::loncoursedata::DownloadCourseInformation($_, - $courseID); - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { - &Apache::loncoursedata::ProcessStudentData(\%cache, - $courseData, $_); - untie(%cache); - } else { - last if($c->aborted()); - next; - } - } else { - untie(%cache); + my $downloadTime=''; + if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + $downloadTime = $cache{$_.':lastDownloadTime'}; + untie(%cache); + } + if($downloadTime eq 'Not downloaded') { + $courseData = + &Apache::loncoursedata::DownloadCourseInformation($_, + $courseID); + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { + last if($c->aborted()); + next; } - } else { - last if($c->aborted()); - next; + &Apache::loncoursedata::ProcessStudentData(\%cache, + $courseData, $_); + untie(%cache); } last if ($c->aborted()); @@ -141,9 +140,9 @@ sub BuildStudentAssessmentPage { } $r->print(''."\n"); if($selected == 0) { - $Ptr .= '

WARNING: '; - $Ptr .= 'Please select a student

'; - $r->print($Ptr); + $Str .= '

WARNING: '; + $Str .= 'Please select a student

'; + $r->print($Str); } return; @@ -152,33 +151,42 @@ sub BuildStudentAssessmentPage { #---- Student Assessment Web Page -------------------------------------------- sub CreateInterface { - my($cache,$selectedName,$students,$formName)=@_; - my $Ptr = ''; - $Ptr .= &CreateLegend(); - $Ptr .= '
'."\n"; - $Ptr .= '{'sectionList'}); my @selectedSections = split(':',$cache->{'sectionsSelected'}); - $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, + $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, \@selectedSections, 'Statistics'); - $Ptr .= '
'."\n"; + $Str .= ''; + $Str .= &CreateColumnSelectionBox($doNotShow); + $Str .= ''."\n"; + $Str .= ''."\n"; @@ -433,41 +447,22 @@ which has a size of four. =cut sub CreateColumnSelectionBox { - my ($CacheData,$headings)=@_; + my ($doNotShow)=@_; - my $missing=0; - my $notThere='Select column to view:'; - my $name; - $notThere .= ''; - $notThere .= '{'count'}; $index++) { + my $name = $doNotShow->{$index.':name'}; + $notThere .= ''."\n"; - $missing++; } - foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { - if(&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) { - next; - } - $name = $CacheData->{$sequence.':title'}; - $notThere .= ''."\n"; - $missing++; - } + $notThere .= ''; - if($missing) { - $notThere .= ''; - } else { - $notThere=''; - } - - return $notThere.''; + return $notThere; } =pod @@ -497,37 +492,24 @@ for consistency of location over the col =cut sub CreateColumnSelectors { - my ($headings)=@_; -=pod - my $found=0; - my ($name, $length, $position); + my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_; - my $present = ''; - for(my $index=0; $index<(scalar @$headings); $index++) { + my $present = ''; + for(my $index=0; $index<(scalar @$infoHeadings); $index++) { $present .= ''; $present .= ''; - $present .= ''; - $found++; + $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />'; + $present .= ''."\n"; } - foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { - if(!&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) { - next; - } + for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) { $present .= ''; $present .= ''; - $present .= ''; - $found++; + $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />'; + $present .= ''."\n"; } - if(!$found) { - $present = ''; - } - - return $present.''."\n";; -=cut + return $present; } #---- END Student Assessment Web Page ---------------------------------------- @@ -602,26 +584,40 @@ sub ShouldShowColumns { my @sequenceKeys=(); my @sequenceHeadings=(); + my %doNotShow; + my $index; + my $count = 0; + my $check = ''; for($index=0; $index < scalar @$headings; $index++) { - push(@infoHeadings, $headings->[$index]); - push(@infoKeys, $cacheKey->[$index]); + $check = 'HeadingColumn'.$headings->[$index]; + if($cache->{'HeadingsFound'} =~ /$check/) { + push(@infoHeadings, $headings->[$index]); + push(@infoKeys, $cacheKey->[$index]); + } else { + $doNotShow{$count.':name'} = $headings->[$index]; + $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index]; + $count++; + } } foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) { - push(@sequenceHeadings, $cache->{$sequence.':title'}); - push(@sequenceKeys, $sequence); + $check = 'SequenceColumn'.$sequence; + if($cache->{'SequencesFound'} eq 'All Sequences' || + $cache->{'SequencesFound'} =~ /$check/) { + push(@sequenceHeadings, $cache->{$sequence.':title'}); + push(@sequenceKeys, $sequence); + } else { + $doNotShow{$count.':name'} = $cache->{$sequence.':title'}; + $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence; + $count++; + } } -# my $headings=$cache->{'form.ChartHeadings'}; -# my $sequences=$cache->{'form.ChartSequences'}; -# if($headings eq 'ALLHEADINGS' || $sequences eq 'ALLSEQUENCES' || -# $headings=~/$test/ || $sequences=~/$test/) { -# return 1; -# } + $doNotShow{'count'} = $count; return (\@infoHeadings, \@infoKeys, \@sequenceHeadings, - \@sequenceKeys); + \@sequenceKeys, \%doNotShow); } #---- END Student Assessment Worker Functions --------------------------------