--- loncom/interface/statistics/lonstudentassessment.pm 2002/07/25 21:23:51 1.2 +++ loncom/interface/statistics/lonstudentassessment.pm 2002/07/26 16:22:09 1.3 @@ -1,7 +1,7 @@ # 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.3 2002/07/26 16:22:09 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,6 +51,31 @@ sub BuildStudentAssessmentPage { $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 $selectedName = &FindSelectedStudent(\%cache, $cache{'StudentAssessmentStudent'}, $students); @@ -83,10 +108,10 @@ sub BuildStudentAssessmentPage { untie(%cache); $courseData = &Apache::loncoursedata::DownloadCourseInformation($_, - $courseID); + $courseID); if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { &Apache::loncoursedata::ProcessStudentData(\%cache, - $courseData, $_); + $courseData, $_); untie(%cache); } else { last if($c->aborted()); @@ -142,6 +167,16 @@ sub CreateInterface { $Ptr .= '{'sectionList'}); + my @selectedSections = split(':',$cache->{'sectionsSelected'}); + $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, + \@selectedSections, + 'Statistics'); + $Ptr .= ''."\n"; return $Ptr; } @@ -151,7 +186,7 @@ sub CreateTableHeadings { $sequenceHeadings)=@_; my $Str = ''; - $Str .= '
'."\n"; + $Str .= '
'."\n"; my $displayString = '
DISPLAYDATAFORMATTING';
@@ -501,31 +536,40 @@ sub CreateColumnSelectors {
 
 sub FindSelectedStudent {
     my($cache, $selectedName, $students)=@_;
-    for(my $index=0; 
-        ($selectedName ne 'All Students') && ($index<(scalar @$students)); 
-        $index++) {
+
+    if($selectedName eq 'All Students' || 
+       $selectedName eq 'No Student Selected') {
+        return $selectedName;
+    }
+
+    for(my $index=0; $index<(scalar @$students); $index++) {
         my $fullname = $cache->{$students->[$index].':fullname'};
         if($fullname eq $selectedName) {
             if($cache->{'StudentAssessmentMove'} eq 'next') {
                 if($index == ((scalar @$students) - 1)) {
                     $selectedName = $students->[0];
+                    return $selectedName;
                 } else {
                     $selectedName = $students->[$index+1];
+                    return $selectedName;
                 }
             } elsif($cache->{'StudentAssessmentMove'} eq 'previous') {
                 if($index == 0) {
                     $selectedName = $students->[-1];
+                    return $selectedName;
                 } else {
                     $selectedName = $students->[$index-1];
+                    return $selectedName;
                 }
             } else {
                 $selectedName = $students->[$index];
+                return $selectedName;
             }
             last;
         }
     }
 
-    return $selectedName;
+    return 'No Student Selected';
 }
 
 =pod