--- loncom/interface/lonhelper.pm 2006/05/05 10:59:51 1.139 +++ loncom/interface/lonhelper.pm 2006/05/09 14:38:10 1.142 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.139 2006/05/05 10:59:51 foxr Exp $ +# $Id: lonhelper.pm,v 1.142 2006/05/09 14:38:10 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2308,7 +2308,7 @@ sub render_student_list { if ($multiselect) { $result .= ''; + $result .= ''; $result .= '
'; - my $size = scalar(keys %$sections); + my $size = scalar(keys(%$sections)); $size += 3; # We have allstudents allpersonel nosection too. if ($size > 5) { $size = 5; @@ -2323,11 +2323,11 @@ sub render_student_list { $result .= ''."\n"; } $result .= ''; - $result .= '
'; + .'.unselect" value="Unselect" onclick='. + "'unselectSections(\"$formprefix.chosensections\", \"$formprefix\")' ".' />'; } # Now we list the students, but the form element type @@ -2370,7 +2370,8 @@ sub render_student_list { .$student->[2] . ':' .$student->[1] . ':' .$student->[3] . ':' - .$student->[4], "<>&\"'") + .$student->[4] . ":" + .$formprefix, "<>&\"'") ."\" />\n"; $result .= HTML::Entities::encode($student->[1], '<>&"') . ''."\n"; @@ -2464,41 +2465,48 @@ sub render { 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 @@ sub render { 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 SCRIPT @@ -2776,19 +2707,18 @@ BUTTONS # if (!$self->{'activeonly'} && ((scalar @$expired_members) > 0)) { - # Past - - $result .= $self->render_student_list(\%sections, - $expired_members, - "past", - \%defaultUsers); - # And future. $result .= $self->render_student_list(\%sections, $future_members, "future", \%defaultUsers); + # Past + + $result .= $self->render_student_list(\%sections, + $expired_members, + "past", + \%defaultUsers); } @@ -3247,11 +3177,9 @@ sub start_section { return if ($token->[2]{'onlysections'}); # add in groups to the end of the list - my %curr_groups; - if (&Apache::loncommon::coursegroups(\%curr_groups)) { - foreach my $group_name (sort(keys(%curr_groups))) { - push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); - } + my %curr_groups = &Apache::loncommon::coursegroups(); + foreach my $group_name (sort(keys(%curr_groups))) { + push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } } @@ -3313,11 +3241,9 @@ sub start_group { # Populate the CHOICES element my %choices; - my %curr_groups; - if (&Apache::loncommon::coursegroups(\%curr_groups)) { - foreach my $group_name (sort(keys(%curr_groups))) { - push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); - } + my %curr_groups = &Apache::loncommon::coursegroups(); + foreach my $group_name (sort(keys(%curr_groups))) { + push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } }