[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Mon, 08 May 2006 22:01:13 -0000
foxr Mon May 8 18:01:13 2006 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
BUG/ENH 3809 - Helper improvements.
o Restricted the action of the listboxes to the segments to which they were
tied.
o Removed dead javascript that will no longer be used.
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.140 loncom/interface/lonhelper.pm:1.141
--- loncom/interface/lonhelper.pm:1.140 Fri May 5 10:35:44 2006
+++ loncom/interface/lonhelper.pm Mon May 8 18:01:11 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.140 2006/05/05 14:35:44 albertel Exp $
+# $Id: lonhelper.pm,v 1.141 2006/05/08 22:01:11 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2324,10 +2324,10 @@
}
$result .= '</td><td valign="top">';
$result .= '<input type="button" name="'.$formprefix.'.select" value="Select" onclick='
- ."'selectSections(\"$formprefix.chosensections\")'".' /></td>';
+ ."'selectSections(\"$formprefix.chosensections\", \"$formprefix\")'".' /></td>';
$result .= '<td valign="top"><input type="button" name="'.$formprefix
.'.unselect" value="Unselect" onclick='.
- "'unselectSections(\"$formprefix.chosensections\")' ".' /></td></tr></table>';
+ "'unselectSections(\"$formprefix.chosensections\", \"$formprefix\")' ".' /></td></tr></table>';
}
# Now we list the students, but the form element type
@@ -2370,7 +2370,8 @@
.$student->[2] . ':'
.$student->[1] . ':'
.$student->[3] . ':'
- .$student->[4], "<>&\"'")
+ .$student->[4] . ":"
+ .$formprefix, "<>&\"'")
."\" /></td><td>\n";
$result .= HTML::Entities::encode($student->[1], '<>&"')
. '</td><td align="center" >'."\n";
@@ -2464,41 +2465,48 @@
return "";
}
}
+ function rightSubForm(element, which) {
+ if (element.value.indexOf(which) != -1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
- function setAllStudents(value) {
+ function setAllStudents(value, which) {
var i;
var ele;
for (i =0; i < document.forms.helpform.elements.length; i++) {
ele = document.forms.helpform.elements[i];
- if(isStudent(ele)) {
+ if(isStudent(ele) && rightSubForm(ele, which)) {
ele.checked=value;
}
}
}
- function setAllCoursePersonnel(value) {
+ function setAllCoursePersonnel(value, which) {
var i;
var ele;
for (i =0; i < document.forms.helpform.elements.length; i++) {
ele = document.forms.helpform.elements[i];
- if(!isStudent(ele)) {
+ if(!isStudent(ele) && rightSubForm(ele, which)) {
ele.checked = value;
}
}
}
- function setSection(which, value) {
+ function setSection(which, value, subform) {
var i;
var ele;
for (i =0; i < document.forms.helpform.elements.length; i++) {
ele = document.forms.helpform.elements[i];
if (ele.value.indexOf(':') != -1) {
- if (section(ele) == which) {
+ if ((section(ele) == which) && rightSubForm(ele, subform)) {
ele.checked = value;
}
}
}
}
- function setCheckboxes(listbox, value) {
+ function setCheckboxes(listbox, which, value) {
var k;
var elem;
var what;
@@ -2508,103 +2516,26 @@
if (elem.options[k].selected) {
what = elem.options[k].text;
if (what == 'All Students') {
- setAllStudents(value);
+ setAllStudents(value, which);
} else if (what == 'All Course Personnel') {
- setAllCoursePersonnel(value);
+ setAllCoursePersonnel(value, which);
} else if (what == 'No Section') {
- setSection('',value);
+ setSection('',value, which);
} else {
- setSection(what, value);
+ setSection(what, value, which);
}
}
}
}
}
- function selectSections(listbox) {
- setCheckboxes(listbox, true);
+ function selectSections(listbox, which) {
+ setCheckboxes(listbox, which, true);
}
- function unselectSections(listbox) {
- setCheckboxes(listbox, false);
- }
- /* ----------------------------- */
-
- function checkall(value, checkName) {
- for (i=0; i<document.forms.helpform.elements.length; i++) {
- ele = document.forms.helpform.elements[i];
- if (ele.name == checkName + '.forminput') {
- document.forms.helpform.elements[i].checked=value;
- }
- }
- }
- function checksec(value) {
- for (i=0; i<document.forms.helpform.elements.length; i++) {
- comp = document.forms.helpform.elements.chksec.value;
- if (document.forms.helpform.elements[i].value.indexOf(':'+comp+':') != -1) {
- if (document.forms.helpform.elements[i].value.indexOf(':Active') != -1) {
- document.forms.helpform.elements[i].checked=value;
- }
- }
- }
- }
- function checkactive() {
- for (i=0; i<document.forms.helpform.elements.length; i++) {
- if (document.forms.helpform.elements[i].value.indexOf(':Active') != -1) {
- document.forms.helpform.elements[i].checked=true;
- }
- }
- }
- function checkexpired() {
- for (i=0; i<document.forms.helpform.elements.length; i++) {
- if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) {
- document.forms.helpform.elements[i].checked=true;
- }
- }
- }
- function uncheckexpired() {
- for (i=0; i<document.forms.helpform.elements.length; i++) {
- if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) {
- document.forms.helpform.elements[i].checked=false;
- }
- }
- }
- 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 unselectSections(listbox, which) {
+ setCheckboxes(listbox, which, false);
}
- function checksections(value) { // Check selected sections.
- numSections = document.forms.helpform.chosensections.length;
- desiredState = getDesiredState();
-
- 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 == "none") {
- 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 (desiredState == hisState ||
- desiredState == "All") {
- if(hisSection == section ||
- section =="" ) {
- document.forms.helpform.elements[i].checked = value;
- }
- }
- }
- }
- }
- }
- }
// -->
</script>
SCRIPT