[LON-CAPA-cvs] cvs: loncom /interface lonselstudent.pm
raeburn
raeburn@source.lon-capa.org
Thu, 15 Jan 2009 18:23:27 -0000
raeburn Thu Jan 15 18:23:27 2009 EDT
Modified files:
/loncom/interface lonselstudent.pm
Log:
- Pass form object along as an additional argument to the following javascript functions:
setAllStudents(), setAllCoursePersonnel(), setSection(), setCheckboxes(), findElement()
can now support cases (e.g., in lonmsgdisplay.pm) where selections for active, previous and future users occur in different forms, but the <script> block containing these functions is only sent once (e.g., for active form), but is used in all three cases (three different forms).
- xhtml multiple="multiple"
Index: loncom/interface/lonselstudent.pm
diff -u loncom/interface/lonselstudent.pm:1.13 loncom/interface/lonselstudent.pm:1.14
--- loncom/interface/lonselstudent.pm:1.13 Tue Nov 4 03:25:53 2008
+++ loncom/interface/lonselstudent.pm Thu Jan 15 18:23:27 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# lonselstudent.pm : Reusable subs for student selection.
#
-# $Id: lonselstudent.pm,v 1.13 2008/11/04 03:25:53 raeburn Exp $
+# $Id: lonselstudent.pm,v 1.14 2009/01/15 18:23:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -197,11 +197,11 @@
<script type="text/javascript">
// <!--
- function findElement(name) {
+ function findElement(name,formname) {
var i;
var ele;
- for(i =0; i < document.forms.$formname.elements.length; i++) {
- ele = document.forms.$formname.elements[i];
+ for(i =0; i < formname.elements.length; i++) {
+ ele = formname.elements[i];
if(ele.name == name) {
return ele;
}
@@ -232,31 +232,31 @@
}
}
- function setAllStudents(value, which) {
+ function setAllStudents(value, which, formname) {
var i;
var ele;
- for (i =0; i < document.forms.$formname.elements.length; i++) {
- ele = document.forms.$formname.elements[i];
+ for (i =0; i < formname.elements.length; i++) {
+ ele = formname.elements[i];
if(isStudent(ele) && rightSubForm(ele, which)) {
ele.checked=value;
}
}
}
- function setAllCoursePersonnel(value, which) {
+ function setAllCoursePersonnel(value, which, formname) {
var i;
var ele;
- for (i =0; i < document.forms.$formname.elements.length; i++) {
- ele = document.forms.$formname.elements[i];
+ for (i =0; i < formname.elements.length; i++) {
+ ele = formname.elements[i];
if(!isStudent(ele) && rightSubForm(ele, which)) {
ele.checked = value;
}
}
}
- function setSection(which, value, subform) {
+ function setSection(which, value, subform, formname) {
var i;
var ele;
- for (i =0; i < document.forms.$formname.elements.length; i++) {
- ele = document.forms.$formname.elements[i];
+ for (i =0; i < formname.elements.length; i++) {
+ ele = formname.elements[i];
if (ele.value.indexOf(':') != -1) {
if ((section(ele) == which) && rightSubForm(ele, subform)) {
ele.checked = value;
@@ -265,34 +265,34 @@
}
}
- function setCheckboxes(listbox, which, value) {
+ function setCheckboxes(listbox, which, value, formname) {
var k;
var elem;
var what;
- elem = findElement(listbox);
+ elem = findElement(listbox, formname);
if (elem != null) {
for (k = 0; k < elem.length; k++) {
if (elem.options[k].selected) {
what = elem.options[k].value;
if (what == 'allstudents') {
- setAllStudents(value, which);
+ setAllStudents(value, which, formname);
} else if (what == 'allpersonnel') {
- setAllCoursePersonnel(value, which);
+ setAllCoursePersonnel(value, which, formname);
} else if (what == 'nosection') {
- setSection('',value, which);
+ setSection('',value, which, formname);
} else {
- setSection(what, value, which);
+ setSection(what, value, which, formname);
}
}
}
}
}
- function selectSections(listbox, which) {
- setCheckboxes(listbox, which, true);
+ function selectSections(listbox, which, formname) {
+ setCheckboxes(listbox, which, true, formname);
}
- function unselectSections(listbox, which) {
- setCheckboxes(listbox, which, false);
+ function unselectSections(listbox, which, formname) {
+ setCheckboxes(listbox, which, false, formname);
}
// -->
@@ -323,7 +323,7 @@
if ($size > 5) {
$size = 5;
}
- $result .= '<select multiple name="'.$formprefix
+ $result .= '<select multiple="multiple" name="'.$formprefix
.'.chosensections" size="'.$size.'">'."\n";
$result .= '<option value="allstudents">'.&mt('All Students').'</option>';
$result .= '<option value="allpersonnel">'.&mt('All Course Personnel').'</option>';
@@ -334,10 +334,10 @@
}
$result .= '</select></td><td valign="top">';
$result .= '<input type="button" name="'.$formprefix.'.select" value="'.&mt('Select').'" onclick='
- ."'selectSections(\"$formprefix.chosensections\", \"$formprefix\")'".' /></td>';
+ ."'selectSections(\"$formprefix.chosensections\", \"$formprefix\", document.forms.$formname)'".' /></td>';
$result .= '<td valign="top"><input type="button" name="'.$formprefix
.'.unselect" value="'.&mt('Unselect').'" onclick='.
- "'unselectSections(\"$formprefix.chosensections\", \"$formprefix\")' ".' /></td></tr></table>';
+ "'unselectSections(\"$formprefix.chosensections\", \"$formprefix\", document.forms.$formname)' ".' /></td></tr></table>';
}
# Now we list the students, but the form element type