--- loncom/interface/lonselstudent.pm 2006/05/17 15:22:32 1.6 +++ loncom/interface/lonselstudent.pm 2006/05/23 21:41:26 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # lonselstudent.pm : Reusable subs for student selection. # -# $Id: lonselstudent.pm,v 1.6 2006/05/17 15:22:32 albertel Exp $ +# $Id: lonselstudent.pm,v 1.7 2006/05/23 21:41:26 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,7 +36,14 @@ use HTML::Entities; # This function produces a list references to four # arrays: # (\@course_personel, \@current_members, \@expired_members, \@future_members) -# +# +# +# Parameters; +# +# restrict - Optional.. if present and defined should be a section name. +# The *_members arrays will then only contain people +# in that section +# # Where: # course_personnel - Each element of this array is itself a reference to an array # containing information about a member of the course staff. @@ -66,6 +73,7 @@ use HTML::Entities; # [4] username:domain of the user. # sub get_people_in_class { + my ($section_restriction) = @_; my %coursepersonnel = &Apache::lonnet::get_course_adv_roles(); # # Enumerate the course_personnel. @@ -114,29 +122,32 @@ sub get_people_in_class { for my $user (@keys) { - - if ( $classlist->{$user}->[$status] eq - 'Active') { - push(@current_members, [$user, $classlist->{$user}->[$fullname], - $classlist->{$user}->[$section], - $classlist->{$user}->[$status], 'Student']); - } else { - # Need to figure out if this user is future or - # Expired... If the start date is in the future - # the user is future...else expired. + if (!$section_restriction || + ($section_restriction eq $classlist->{$user}->[$section])) { - my $now = time; - if ($classlist->{$user}->[$start_date] > $now) { - push(@future_members, [$user, $classlist->{$user}->[$fullname], + if ( $classlist->{$user}->[$status] eq + 'Active') { + push(@current_members, [$user, $classlist->{$user}->[$fullname], $classlist->{$user}->[$section], - "Future", "Student"]); + $classlist->{$user}->[$status], 'Student']); } else { - push(@expired_members, [$user, - $classlist->{$user}->[$fullname], - $classlist->{$user}->[$section], - "Expired", "Student"]); + # Need to figure out if this user is future or + # Expired... If the start date is in the future + # the user is future...else expired. + + my $now = time; + if ($classlist->{$user}->[$start_date] > $now) { + push(@future_members, [$user, $classlist->{$user}->[$fullname], + $classlist->{$user}->[$section], + "Future", "Student"]); + } else { + push(@expired_members, [$user, + $classlist->{$user}->[$fullname], + $classlist->{$user}->[$section], + "Expired", "Student"]); + } + } - } } return (\@course_personnel,