--- loncom/interface/lonselstudent.pm 2006/05/15 22:01:12 1.2 +++ loncom/interface/lonselstudent.pm 2006/05/17 15:20:56 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # lonselstudent.pm : Reusable subs for student selection. # -# $Id: lonselstudent.pm,v 1.2 2006/05/15 22:01:12 foxr Exp $ +# $Id: lonselstudent.pm,v 1.5 2006/05/17 15:20:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,20 +71,19 @@ sub get_people_in_class { # Enumerate the course_personnel. # my @course_personnel; - for (sort keys %coursepersonnel) { - for my $role (split /,/, $coursepersonnel{$_}) { - # extract the names so we can sort them - my @people; - - for (split /,/, $role) { - push @people, [split /:/, $role]; - } - - @people = sort { $a->[0] cmp $b->[0] } @people; + for my $role (sort(keys(%coursepersonnel))) { + # extract the names so we can sort them + my @people; + for my $person (split(/,/, $coursepersonnel{$role})) { + my ($uname,$domain) = split(/:/, $person); + push(@people, [&Apache::loncommon::plainname($uname,$domain), + $uname,$domain]); + } + @people = sort { $a->[0] cmp $b->[0] } (@people); - for my $person (@people) { - push @course_personnel, [join(':', @$person), $person->[0], '', $_]; - } + for my $person (@people) { + push(@course_personnel, [join(':', $person->[1],$person->[2]), + $person->[0], '', '', $role]); } } # Students must be split into the three categories: @@ -102,14 +101,14 @@ sub get_people_in_class { my $classlist = &Apache::loncoursedata::get_classlist(); - my @keys = keys %{$classlist}; + my @keys = keys(%{$classlist}); # Sort by: Section, name @keys = sort { if ($classlist->{$a}->[$section] ne $classlist->{$b}->[$section]) { return $classlist->{$a}->[$section] cmp $classlist->{$b}->[$section]; } return $classlist->{$a}->[$fullname] cmp $classlist->{$b}->[$fullname]; - } @keys; + } (@keys); @@ -118,9 +117,9 @@ sub get_people_in_class { if ( $classlist->{$_}->[$status] eq 'Active') { - push @current_members, [$_, $classlist->{$_}->[$fullname], + push(@current_members, [$_, $classlist->{$_}->[$fullname], $classlist->{$_}->[$section], - $classlist->{$_}->[$status], 'Student']; + $classlist->{$_}->[$status], 'Student']); } else { # Need to figure out if this user is future or # Expired... If the start date is in the future @@ -128,13 +127,13 @@ sub get_people_in_class { my $now = time; if ($classlist->{$_}->[$start_date] > $now) { - push @future_members, [$_, $classlist->{$_}->[$fullname], + push(@future_members, [$_, $classlist->{$_}->[$fullname], $classlist->{$_}->[$section], - "Future", "Student"]; + "Future", "Student"]); } else { - push @expired_members, [$_, $classlist->{$_}->[$fullname], + push(@expired_members, [$_, $classlist->{$_}->[$fullname], $classlist->{$_}->[$section], - "Expired", "Student"]; + "Expired", "Student"]); } } @@ -330,12 +329,14 @@ SCRIPT # True -> checkboxes. # False -> radiobuttons. - $result .= "
Name | '."\n"; - $result .= 'Section | '."\n"; - $result .= 'Status | '."\n"; - $result .= 'Role | '."\n"; - $result .= 'Username : Domain | Name | '."\n"; + $result .= 'Section | '."\n"; + $result .= 'Status | '."\n"; + $result .= 'Role | '."\n"; + $result .= 'Username : Domain | '."\n"; + $result .= &Apache::loncommon::end_data_table_header_row(); my $input_type; if ($multiselect) { @@ -346,13 +347,14 @@ SCRIPT my $checked = 0; for my $student (@$students) { - $result .= '
---|---|---|---|---|---|
[0]; # Figure out which students are checked by default... - if(%$defaultusers) { + if (%$defaultusers) { if (exists ($defaultusers->{$user})) { $result .= ' checked ="checked" '; $checked = 1; @@ -361,25 +363,27 @@ SCRIPT $result .= ' checked="checked" '; $checked = 1; # First one for radio if no default specified. } - $result .= ' value="'. HTML::Entities::encode($user . ':' - .$student->[2] . ':' + $result .= ' value="'.&HTML::Entities::encode($user . ':' + .$student->[2] . ':' .$student->[1] . ':' .$student->[3] . ':' .$student->[4] . ":" .$formprefix, "<>&\"'") ."\" /> | \n"; - $result .= HTML::Entities::encode($student->[1], '<>&"') + $result .= &HTML::Entities::encode($student->[1], '<>&"') . ' | '."\n"; - $result .= HTML::Entities::encode($student->[2], '<>&"') + $result .= &HTML::Entities::encode($student->[2], '<>&"') . ' | '."\n"; - $result .= HTML::Entities::encode($student->[3], '<>&"') + $result .= &HTML::Entities::encode($student->[3], '<>&"') . ' | '."\n"; - $result .= HTML::Entities::encode($student->[4], '<>&"') + $result .= &HTML::Entities::encode($student->[4], '<>&"') . ' | '."\n"; - $result .= HTML::Entities::encode($student->[0], '<>&"') - . ' |