--- loncom/interface/statistics/lonstudentassessment.pm 2002/07/25 21:23:51 1.2 +++ loncom/interface/statistics/lonstudentassessment.pm 2002/12/11 18:41:00 1.20 @@ -1,12 +1,11 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstudentassessment.pm,v 1.2 2002/07/25 21:23:51 stredwic Exp $ +# $Id: lonstudentassessment.pm,v 1.20 2002/12/11 18:41:00 minaeibi 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 @@ -42,83 +41,143 @@ 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)) { + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $r->print('
Unable to tie database.'); 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); + } + } + 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)); + $r->rflush(); - my $Ptr = ''; + my $Str = ''; if($selectedName eq 'No Student Selected') { - $Ptr .= ''."\n"); foreach (@$students) { - next if ($_ ne $selectedName && + if($c->aborted()) { return $Str; } + next if ($_ ne $selectedName && $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()); + + my @who = ($_); + next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true', + $cacheDB, 'true', + 'false', $courseID, + $r, $c) ne 'OK'); + next if($c->aborted()); + + if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + my @before=(); + my @after=(); + my @updateColumn=(); + my $foundUpdate = 0; + foreach(@$infoKeys) { + if(/updateTime/) { + $foundUpdate=1; + push(@updateColumn, $_); next; } - } else { - untie(%cache); + if($foundUpdate) { + push(@after, $_); + } else { + push(@before, $_); + } } - } else { - last if($c->aborted()); - next; - } + my $displayString = 'DISPLAYDATA'.$spacing; + $r->print(&Apache::lonhtmlcommon::FormatStudentInformation( + \%cache, $_, + \@before, + $displayString, + 'preformatted')); - last if ($c->aborted()); + if($foundUpdate) { + $displayString = ''; + $displayString .= ''; + $displayString .= 'DISPLAYDATA'.$spacing; + $r->print(&Apache::lonhtmlcommon::FormatStudentInformation( + \%cache, $_, + \@updateColumn, + $displayString, + 'preformatted')); + } - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - my $displayString = 'DISPLAYDATA'.$spacing; + $displayString = 'DISPLAYDATA'.$spacing; $r->print(&Apache::lonhtmlcommon::FormatStudentInformation( \%cache, $_, - $infoKeys, + \@after, $displayString, 'preformatted')); $r->print(&StudentReport(\%cache, $_, $spacing, $sequenceKeys)); $r->print("\n"); + $r->rflush(); untie(%cache); } } + + +# $r->print("AverageTtal"); +# $r->print(&StudentAverageTotal(\%cache, $spacing, $sequenceKeys)); +# $r->print("\n"); +# $r->rflush(); + untie(%cache); + + $r->print(''."\n"); if($selected == 0) { - $Ptr .= '
'."\n"; - $Ptr .= '{'sectionList'}); + my @selectedSections = split(':',$cache->{'sectionsSelected'}); + $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, + \@selectedSections, + 'Statistics'); + $Str .= ' | '; + $Str .= &CreateColumnSelectionBox($doNotShow); + $Str .= ' | '."\n";
+ $Str .= 'DISPLAYDATAFORMATTING'; $displayString .= $spacing.' | '."\n";
- $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
+ $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
$infoKeys,
$infoHeadings,
$displayString,
'preformatted');
- $displayString = 'DISPLAYDATA'.$spacing; + $displayString = ' "; return $Str; } @@ -373,7 +515,7 @@ sub CreateLegend { =item &CreateColumnSelectionBox() If there are columns not being displayed then this selection box is created -with a list of those columns. When selections are made and the page +with a list of those columns. When selections are made and the page refreshed, the columns will be removed from this box and the column is put back in the chart. If there is no columns to select, no row is added to the interface table. @@ -384,13 +526,13 @@ Input: $CacheData, $headings $CacheData: A pointer to a hash tied to the cached data -$headings: An array of the names of the columns for the student information. +$headings: An array of the names of the columns for the student information. They are used for displaying which columns are missing. Output: $notThere -$notThere: The string contains one row of a table. The first column has the -name of the selection box. The second contains the selection box +$notThere: The string contains one row of a table. The first column has the +name of the selection box. The second contains the selection box which has a size of four. =back @@ -398,48 +540,29 @@ 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 .= ''; - } else { - $notThere=' | |||
'; - } - - return $notThere.' | ||||
'; $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.'