[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Wed, 28 Sep 2005 10:37:35 -0000
foxr Wed Sep 28 06:37:35 2005 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
enhancement bug: Improve the user interface for selecting
students from multiple sections.
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.112 loncom/interface/lonhelper.pm:1.113
--- loncom/interface/lonhelper.pm:1.112 Tue Jul 12 12:11:19 2005
+++ loncom/interface/lonhelper.pm Wed Sep 28 06:37:33 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.112 2005/07/12 16:11:19 albertel Exp $
+# $Id: lonhelper.pm,v 1.113 2005/09/28 10:37:33 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2243,6 +2243,39 @@
}
}
}
+ function getDesiredState() { // Return desired person state radio value.
+ numRadio = document.forms.helpform.personstate.length;
+ for (i =0; i < numRadio; i++) {
+ if (document.forms.helpform.personstate[i].checked) {
+ return document.forms.helpform.personstate[i].value;
+ }
+ }
+ return "";
+ }
+
+ function checksections(value) { // Check selected sections.
+ numSections = document.forms.helpform.chosensections.length;
+ desiredState = getDesiredState();
+
+ for (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.
+ section ="";
+ }
+ for (i = 0; i < document.forms.helpform.elements.length; i++ ) {
+ if (document.forms.helpform.elements[i].value.indexOf(':') != -1) {
+ 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;
+ }
+ }
+ }
+ }
+ }
+ }
// -->
</script>
SCRIPT
@@ -2258,23 +2291,12 @@
$buttons = <<BUTTONS;
<br />
<table>
- <tr>
- <td><input type="button" onclick="checkactive()" value="$lt{'ocs'}" /></td>
- <td><input type="button" onclick="uncheckexpired()" value="$lt{'ues'}" /><br /></td>
- </tr>
<tr>
<td><input type="button" onclick="checkall(true, '$var')" value="$lt{'sas'}" /></td>
<td> <input type="button" onclick="checkall(false, '$var')" value="$lt{'uas'}" /><br /></td>
</tr>
- <tr>
- <td><input type="button" onclick="checksec(true)" value="$lt{'sfsg'}"></td>
- <td><input type="text" size="5" name="chksec"> </td>
- </tr>
- <tr>
- <td><input type="button" onclick="checksec(false)" value="$lt{'ufsg'}"></td>
- <td></td>
- </tr>
+
</table>
<br />
BUTTONS
@@ -2372,8 +2394,43 @@
}
$result .= "</table>\n\n";
- $result .= $buttons;
-
+ $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;
+ }
+ }
+ # The variable $choice_widget will have the html to make the choice
+ # selector.
+
+ 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><input type="radio" name="personstate" value="Active" checked />';
+ $section_selectors .= " Current Students</td>\n";
+ $section_selectors .= ' <td><input type="radio" name="personstate" value="All" />';
+ $section_selectors .= " All students</td>\n";
+ $section_selectors .= ' <td><input type="radio" name="personstate" value="Expired" />';
+ $section_selectors .= " Expired Students</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>'."\n</TABLE>\n";
+ $section_selectors .= "<br />";
+
+ $result .= $section_selectors;
return $result;
}