--- loncom/interface/lonhelper.pm 2006/04/24 23:20:37 1.138 +++ loncom/interface/lonhelper.pm 2006/05/05 10:59:51 1.139 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.138 2006/04/24 23:20:37 albertel Exp $ +# $Id: lonhelper.pm,v 1.139 2006/05/05 10:59:51 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -184,6 +184,7 @@ use Apache::lonxml; use Apache::lonlocal; use Apache::lonnet; + # Register all the tags with the helper, so the helper can # push and pop them @@ -2274,6 +2275,119 @@ use strict; use Apache::lonlocal; use Apache::lonnet; +# +# Utility function used when rendering the tag. +# This function renders a segment of course personel +# Personel are broken up by the helper into past, current and +# future...each one gets is own subpage of selection. +# This sub renders one of these pages. +# Parameters: +# $sections - Set of sections in the course (hash reference). +# $students - Students in the section. (ref to array of references +# to arrays). +# $formprefix - form path prefix for form element names +# This is used to make each form element +# so that the segments having to do with each +# set of students won't collide. +# $defaultusers - reference to a hash containng +# the set of users that should be on or off. +# Returns: +# HTML text to add to the rendering of the helper. +# +sub render_student_list { + my ($self, + $sections, $students, $formprefix, $defaultusers) = @_; + + my $multiselect = $self->{'multichoice'}; + my $result = ""; + + # 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. + + if ($multiselect) { + $result .= ''; + $result .= '
'; + + my $size = scalar(keys %$sections); + $size += 3; # We have allstudents allpersonel nosection too. + if ($size > 5) { + $size = 5; + } + $result .= ''; + $result .= '
'; + } + + # Now we list the students, but the form element type + # will depend on whether or not multiselect is true. + # True -> checkboxes. + # False -> radiobuttons. + + $result .= "\n"; + $result .= ''."\n"; + $result .= ' '."\n"; + $result .= ' '."\n"; + $result .= ' '."\n"; + $result .= ' '."\n"; + + my $input_type; + if ($multiselect) { + $input_type = "checkbox"; + } else { + $input_type = "radio"; + } + + my $checked = 0; + for my $student (@$students) { + $result .= ''."\n"; + } + $result .="
NameSectionStatusRoleUsername : Domain
[0]; + + # Figure out which students are checked by default... + + if(%$defaultusers) { + if (exists ($defaultusers->{$user})) { + $result .= ' checked ="checked" '; + $checked = 1; + } + } elsif (!$self->{'multichoice'} && !$checked) { + $result .= ' checked="checked" '; + $checked = 1; # First one for radio if no default specified. + } + $result .= ' value="'. HTML::Entities::encode($user . ':' + .$student->[2] . ':' + .$student->[1] . ':' + .$student->[3] . ':' + .$student->[4], "<>&\"'") + ."\" />\n"; + $result .= HTML::Entities::encode($student->[1], '<>&"') + . ''."\n"; + $result .= HTML::Entities::encode($student->[2], '<>&"') + . ''."\n"; + $result .= HTML::Entities::encode($student->[3], '<>&"') + . ''."\n"; + $result .= HTML::Entities::encode($student->[4], '<>&"') + . ''."\n"; + $result .= HTML::Entities::encode($student->[0], '<>&"') + . '


\n"; + + return $result; +} + BEGIN { &Apache::lonhelper::register('Apache::lonhelper::student', ('student')); @@ -2322,6 +2436,99 @@ sub render { $result = < //