--- loncom/interface/lonhelper.pm 2006/05/05 10:59:51 1.139
+++ loncom/interface/lonhelper.pm 2006/05/09 21:44:18 1.145
@@ -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.145 2006/05/09 21:44:18 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2291,16 +2291,131 @@ use Apache::lonnet;
# set of students won't collide.
# $defaultusers - reference to a hash containng
# the set of users that should be on or off.
+# $multiselect - True if multiselect allowed.
+# $resultname - Name of result variable.
+# $javascript - If true, the javascript to run this is output
+# This should be true for the first call for a page
+# and false for all other calls... only matters if
+# multiselect is true.
# Returns:
# HTML text to add to the rendering of the helper.
#
sub render_student_list {
- my ($self,
- $sections, $students, $formprefix, $defaultusers) = @_;
+ my (
+ $sections, $students, $formprefix, $defaultusers,
+ $multiselect, $resultname, $javascript) = @_;
- my $multiselect = $self->{'multichoice'};
my $result = "";
+ if ($javascript && $multiselect) {
+ $result .= <
+SCRIPT
+
+ }
+
# If multiple selections are allowed, we have a listbox
# at the top which allows quick selections from each section
# as well as from categories of personnel.
@@ -2308,7 +2423,7 @@ sub render_student_list {
if ($multiselect) {
$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 +2438,11 @@ sub render_student_list {
$result .= ''."\n";
}
$result .= '
';
- $result .= '
';
+ $result .= '';
$result .= '
';
+ .'.unselect" value="Unselect" onclick='.
+ "'unselectSections(\"$formprefix.chosensections\", \"$formprefix\")' ".' />';
}
# Now we list the students, but the form element type
@@ -2352,7 +2467,7 @@ sub render_student_list {
my $checked = 0;
for my $student (@$students) {
$result .= '
[0];
# Figure out which students are checked by default...
@@ -2362,7 +2477,7 @@ sub render_student_list {
$result .= ' checked ="checked" ';
$checked = 1;
}
- } elsif (!$self->{'multichoice'} && !$checked) {
+ } elsif (!$multiselect && !$checked) {
$result .= ' checked="checked" ';
$checked = 1; # First one for radio if no default specified.
}
@@ -2370,7 +2485,8 @@ sub render_student_list {
.$student->[2] . ':'
.$student->[1] . ':'
.$student->[3] . ':'
- .$student->[4], "<>&\"'")
+ .$student->[4] . ":"
+ .$formprefix, "<>&\"'")
."\" />