--- loncom/interface/lonstatistics.pm 2003/04/21 15:12:37 1.67 +++ loncom/interface/lonstatistics.pm 2003/05/27 14:51:24 1.71 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstatistics.pm,v 1.67 2003/04/21 15:12:37 matthew Exp $ +# $Id: lonstatistics.pm,v 1.71 2003/05/27 14:51:24 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -206,7 +206,6 @@ upon the calling context. ####################################################### ####################################################### sub PrepareClasslist { - my $r = shift; my %Sections; &clear_classlist_variables(); # @@ -230,6 +229,11 @@ sub PrepareClasslist { } } # + # Deal with instructors with restricted section access + if ($ENV{'request.course.sec'} !~ /^\s*$/) { + @SelectedSections = ($ENV{'request.course.sec'}); + } + # # Set up %StudentData @StudentDataOrder = qw/fullname username domain id section status/; foreach my $field (@StudentDataOrder) { @@ -238,7 +242,10 @@ sub PrepareClasslist { $StudentData{$field}->{'width'} = $StudentData{$field}->{'base_width'}; } - + # + # get the status requested + my $requested_status = 'Active'; + $requested_status = $ENV{'form.Status'} if (exists($ENV{'form.Status'})); # # Process the classlist while (my ($student,$student_data) = each (%$classlist)) { @@ -266,7 +273,11 @@ sub PrepareClasslist { # # Only put in the list those students we are interested in foreach my $sect (@SelectedSections) { - if (($sect eq 'all') || ($section eq $sect)) { + if ( (($sect eq 'all') || + ($section eq $sect)) && + (($studenthash->{'status'} eq $requested_status) || + ($requested_status eq 'Any')) + ){ push (@Students,$studenthash); last; } @@ -274,8 +285,12 @@ sub PrepareClasslist { } # # Put the consolidated section data in the right place - @Sections = sort {$a cmp $b} keys(%Sections); - unshift(@Sections,'all'); # Put 'all' at the front of the list + if ($ENV{'request.course.sec'} !~ /^\s*$/) { + @Sections = ($ENV{'request.course.sec'}); + } else { + @Sections = sort {$a cmp $b} keys(%Sections); + unshift(@Sections,'all'); # Put 'all' at the front of the list + } # # Sort the Students my $sortby = 'fullname'; @@ -326,6 +341,27 @@ sub PrepareClasslist { return; } + +####################################################### +####################################################### + +=pod + +=item get_students + +Returns a list of the selected students + +=cut + +####################################################### +####################################################### +sub get_students { + if (! @Students) { + &PrepareClasslist() + } + return @Students; +} + ####################################################### ####################################################### @@ -723,6 +759,7 @@ sub MapSelect { Returns html for a selection box allowing the user to choose one (or more) of the sections in the course. +Uses the package variables @Sections and @SelectedSections =over 4 =item $elementname The name of the HTML form element @@ -731,13 +768,6 @@ of the sections in the course. =item $numvisible The number of options to be visible -=item $selected Array ref to the names of the already selected sections. -If undef, $ENV{'form.'.$elementname} is used. -If $ENV{'form.'.$elementname} is also empty, none will be selected. - -=item $restriction Code reference to subroutine which returns true or -false. The code must expect a reference to a sequence data structure. - =back =cut @@ -750,6 +780,11 @@ sub SectionSelect { return; } # + # Make sure we have the data we need to continue + if (! @Sections) { + &PrepareClasslist() + } + # # Build the form element my $Str = "\n"; $Str .= '