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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 01 Oct 2005 02:28:57 -0000


albertel		Fri Sep 30 22:28:57 2005 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  - the state restriction wasn't taking effect
  - don't need to show the selectors when selcting only 1 user
  - restrict the height of the multi selector to no more than 5 intems
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.115 loncom/interface/lonhelper.pm:1.116
--- loncom/interface/lonhelper.pm:1.115	Wed Sep 28 15:03:42 2005
+++ loncom/interface/lonhelper.pm	Fri Sep 30 22:28:55 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.115 2005/09/28 19:03:42 albertel Exp $
+# $Id: lonhelper.pm,v 1.116 2005/10/01 02:28:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2257,10 +2257,10 @@
         numSections  = document.forms.helpform.chosensections.length;
 	desiredState = getDesiredState();
 
-	for (option = 0; option , numSections; option++) {
+	for (var option = 0; option < numSections; option++) {
 	    if(document.forms.helpform.chosensections.options[option].selected) {
 		section = document.forms.helpform.chosensections.options[option].text;
-		if (section == "Staff") {   // Staff are indicated by an empty section.
+		if (section == "none") {
 		    section ="";
 		}
 		for (i = 0; i < document.forms.helpform.elements.length; i++ ) {
@@ -2268,8 +2268,12 @@
 			info = document.forms.helpform.elements[i].value.split(':');
 			hisSection = info[2];
 			hisState   = info[4];
-                        if((hisSection == section)  && ((desiredState ==hisState) ||  (section =="") || (desiredState == "All"))) {
-			    document.forms.helpform.elements[i].checked = value;
+			if (desiredState == hisState ||
+			    desiredState == "All") {
+			    if(hisSection == section ||
+			       section =="" ) {
+				document.forms.helpform.elements[i].checked = value;
+			    }
 			}
 		    }
 		}
@@ -2397,41 +2401,48 @@
     $result .= $buttons;   
     #
     #  now add the fancy section choice... first enumerate the sections:
-
-    my %sections;
-    for my $key (@keys) {
-	my $section_name = $classlist->{$key}->[$section];
-	if ($section_name ne "") {
-	    $sections{$section_name} = 1;
+    if ($self->{'multichoice'}) {
+	my %sections;
+	for my $key (@keys) {
+	    my $section_name = $classlist->{$key}->[$section];
+	    if ($section_name ne "") {
+		$sections{$section_name} = 1;
+	    }
 	}
-    }
-    #  The variable $choice_widget will have the html to make the choice 
-    #  selector.
+	#  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 $choice_widget = '<select multiple name="chosensections" size="'.$size.'">'."\n";
+	foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) {
+	    $choice_widget .= "<option name=\"$sec\">$sec</option>\n";
+	}
+	$choice_widget .= "<option>none</option></select>\n";
 
-    my $choice_widget = '<select multiple name="chosensections" size="5">'."\n";
-    foreach my $sec (sort (keys %sections)) {
-	$choice_widget .= "<option name=\"$sec\">$sec</option>\n";
-    }
-    $choice_widget .= "<option>Staff</option></select>\n";
-
-    # Build a table without any borders to contain the section based
-    # selection:
-
-    my $section_selectors = '<table border="0">'."\n";
-    $section_selectors   .= "<tr valign=\"top\">\n<td>For Sections:</td><td>$choice_widget</td>\n";
-    $section_selectors   .= '    <td><label><input type="radio" name="personstate" value="Active" checked />';
-    $section_selectors   .= "         Current Students</label></td>\n";
-    $section_selectors   .= '    <td><label><input type="radio" name="personstate" value="All" />';
-    $section_selectors   .= "         All students</label></td>\n";
-    $section_selectors   .= '    <td><label><input type="radio" name="personstate" value="Expired" />';
-    $section_selectors   .= "          Expired Students</label></td>\n";
-    $section_selectors   .= "</tr>\n";
-    $section_selectors   .= "<tr>\n";
-    $section_selectors   .= '    <td><input type="button" value="Select" onclick="checksections(true);" /></td>'."\n";
-    $section_selectors   .= '    <td><input type="button" value="Unselect" onclick="checksections(false);" /></td></tr>'."\n</table>\n";
-    $section_selectors   .= "<br />";
+	# Build a table without any borders to contain the section based
+	# selection:
 
-    $result .= $section_selectors;
+	my $section_selectors =<<SECTIONSELECT;
+<table border="0">
+  <tr valign="top">
+   <td>For Sections:</td><td>$choice_widget</td>
+   <td><label><input type="radio" name="personstate" value="Active" checked />
+               Current Students</label></td>
+   <td><label><input type="radio" name="personstate" value="All" />
+               All students</label></td>
+   <td><label><input type="radio" name="personstate" value="Expired" />
+               Expired Students</label></td>
+  </tr>
+  <tr>
+   <td><input type="button" value="Select" onclick="checksections(true);" /></td>
+   <td><input type="button" value="Unselect" onclick="checksections(false);" /></td></tr>
+</table>
+<br />
+SECTIONSELECT
+         $result .= $section_selectors;
+    }
     return $result;
 }