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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 09 May 2006 22:15:32 -0000


foxr		Tue May  9 18:15:32 2006 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  More work to make renering a student list indepedendent of a helper if need be.
  
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.145 loncom/interface/lonhelper.pm:1.146
--- loncom/interface/lonhelper.pm:1.145	Tue May  9 17:44:18 2006
+++ loncom/interface/lonhelper.pm	Tue May  9 18:15:30 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.145 2006/05/09 21:44:18 foxr Exp $
+# $Id: lonhelper.pm,v 1.146 2006/05/09 22:15:30 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2282,7 +2282,6 @@
 #  future...each one gets is own subpage of selection.
 #  This sub renders one of these pages.
 #  Parameters:
-#     $sections    - Set of sections in the course (hash reference).
 #     $students    - Students in the section. (ref to array of references
 #                    to arrays).
 #     $formprefix  - form path prefix for form element names
@@ -2301,8 +2300,7 @@
 #     HTML  text to add to the rendering of the helper.
 #
 sub render_student_list {
-    my (
-	$sections, $students, $formprefix, $defaultusers,
+    my ($students, $formprefix, $defaultusers,
 	$multiselect, $resultname, $javascript) = @_;
 
     my $result = "";
@@ -2421,9 +2419,19 @@
     # as well as from categories of personnel.
 
     if ($multiselect) {
+	#  Make a section hash so we can add sections to the choice:
+
+	my %sections;
+	for my $student (@$students) {
+	    my $sect = $student->[2];
+	    if ($sect ne "") {
+		$sections{$sect} = 1;
+	    }
+	}
+
 	$result .= '<table><tr><td>';
 
-	my $size = scalar(keys(%$sections));
+	my $size = scalar(keys(%sections));
 	$size += 3;		# We have allstudents allpersonel nosection too.
 	if ($size > 5) { 
 	    $size = 5; 
@@ -2434,7 +2442,7 @@
 	$result .= '<option name="allpersonnel">All Course Personnel</option>';
 	$result .= '<option name="nosection">No Section</option>';
 	$result .= "\n";
-	foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%$sections))) {
+	foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) {
 	    $result .= '<option name="'.$sec.'">'.$sec.'</option>'."\n";
 	}
 	$result .= '</td><td valign="top">';
@@ -2651,44 +2659,15 @@
     }
 
 
-    # Create a list of the sections that can be used to create the section 
-    # selection list boxes:
-    #
-    my %sections;
-    for my $key (@keys) {
-	my $section_name = $classlist->{$key}->[$section];
-	if ($section_name ne "") {
-	    $sections{$section_name} = 1;
-	}
-    }
-
-
-    if ($self->{'multichoice'}) {
-
-	#  The variable $choice_widget will have the html to make the choice 
-	#  selector.
-	my $size=5;
-	if (scalar(keys(%sections)) < 5) {
-	    $size=scalar(keys(%sections));
-	}
-	my $result = '<select multiple name="chosensections" size="'.$size.'">'."\n";
-	foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) {
-	    $result .= "<option name=\"$sec\">$sec</option>\n";
-	}
-	$result .= "<option>none</option></select>\n";
-
-
-    }
 
     #   Current personel
 
-    $result .= &render_student_list(\%sections,
-					  $current_members,
-					  "current",
-					  \%defaultUsers,
-				    $self->{'multichoice'},
-				    $self->{'variable'},
-				    1);
+    $result .= &render_student_list( $current_members,
+				     "current",
+				     \%defaultUsers,
+				     $self->{'multichoice'},
+				     $self->{'variable'},
+				     1);
 
 
     # If activeonly is not set then we can also give the expired students:
@@ -2697,19 +2676,17 @@
 
 	# And future.
 
-	$result .= &render_student_list(\%sections,
-					      $future_members,
-					      "future",
-					      \%defaultUsers,
-					$self->{'multichoice'},
-					$self->{'variable'},
-					0);
+	$result .= &render_student_list( $future_members,
+					 "future",
+					 \%defaultUsers,
+					 $self->{'multichoice'},
+					 $self->{'variable'},
+					 0);
 	# Past 
 
-	$result .= &render_student_list(\%sections,
-					      $expired_members,
-					      "past",
-					      \%defaultUsers,
+	$result .= &render_student_list($expired_members,
+					"past",
+					\%defaultUsers,
 					$self->{'multichoice'},
 					$self->{'variable'},
 					0);