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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 09 May 2006 21:39:47 -0000


foxr		Tue May  9 17:39:47 2006 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  Bit by bit pulling the render_student_list into an independently callable
  sub and doing some cleanup.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.143 loncom/interface/lonhelper.pm:1.144
--- loncom/interface/lonhelper.pm:1.143	Tue May  9 14:15:39 2006
+++ loncom/interface/lonhelper.pm	Tue May  9 17:39:47 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.143 2006/05/09 18:15:39 albertel Exp $
+# $Id: lonhelper.pm,v 1.144 2006/05/09 21:39:47 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2291,14 +2291,16 @@
 #                    set of students won't collide.
 #     $defaultusers - reference to a hash containng
 #                     the set of users that should be on or off.
+#     $multiselect  - True if multiselect allowed.
+#     $resultname   - Name of result variable.
 #  Returns:
 #     HTML  text to add to the rendering of the helper.
 #
 sub render_student_list {
-    my ($self,
-	$sections, $students, $formprefix, $defaultusers) = @_;
+    my (
+	$sections, $students, $formprefix, $defaultusers,
+	$multiselect, $resultname) = @_;
 
-    my $multiselect = $self->{'multichoice'};
     my $result = "";
 
     # If multiple selections are allowed, we have a listbox
@@ -2352,7 +2354,7 @@
     my $checked = 0;
     for my $student (@$students) {
 	$result .= '<tr><td><input type="'.$input_type.'"  name="'.
-	    $self->{'variable'}.".forminput".'"';
+	    $resultname.".forminput".'"';
 	my $user    = $student->[0];
 
 	# Figure out which students are checked by default...
@@ -2362,7 +2364,7 @@
 		$result .= ' checked ="checked" ';
 		$checked = 1;
 	    }
-	} elsif (!$self->{'multichoice'} && !$checked) {
+	} elsif (!$multiselect  && !$checked) {
 	    $result .= ' checked="checked" ';
 	    $checked = 1;	# First one for radio if no default specified.
 	}
@@ -2697,10 +2699,12 @@
 
     #   Current personel
 
-    $result .= $self->render_student_list(\%sections,
+    $result .= &render_student_list(\%sections,
 					  $current_members,
 					  "current",
-					  \%defaultUsers);
+					  \%defaultUsers,
+				    $self->{'multichoice'},
+				    $self->{'variable'});
 
 
     # If activeonly is not set then we can also give the expired students:
@@ -2709,16 +2713,20 @@
 
 	# And future.
 
-	$result .= $self->render_student_list(\%sections,
+	$result .= &render_student_list(\%sections,
 					      $future_members,
 					      "future",
-					      \%defaultUsers);
+					      \%defaultUsers,
+					$self->{'multichoice'},
+					$self->{'variable'});
 	# Past 
 
-	$result .= $self->render_student_list(\%sections,
+	$result .= &render_student_list(\%sections,
 					      $expired_members,
 					      "past",
-					      \%defaultUsers);
+					      \%defaultUsers,
+					$self->{'multichoice'},
+					$self->{'variable'});
     }