[LON-CAPA-cvs] cvs: loncom /interface lonselstudent.pm

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 23 May 2006 21:41:27 -0000


foxr		Tue May 23 17:41:27 2006 EDT

  Modified files:              
    /loncom/interface	lonselstudent.pm 
  Log:
  Support restricting student listings to sections that the current user
  has a role in
  
  
Index: loncom/interface/lonselstudent.pm
diff -u loncom/interface/lonselstudent.pm:1.6 loncom/interface/lonselstudent.pm:1.7
--- loncom/interface/lonselstudent.pm:1.6	Wed May 17 11:22:32 2006
+++ loncom/interface/lonselstudent.pm	Tue May 23 17:41:26 2006
@@ -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 @@
 #  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 @@
 #       [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 @@
 
 
     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,