version 1.38, 2003/06/17 14:21:22
|
version 1.39, 2003/06/19 19:28:52
|
Line 1775 package Apache::lonhelper::student;
|
Line 1775 package Apache::lonhelper::student;
|
Student elements display a choice of students enrolled in the current |
Student elements display a choice of students enrolled in the current |
course. Currently it is primitive; this is expected to evolve later. |
course. Currently it is primitive; this is expected to evolve later. |
|
|
Student elements take two attributes: "variable", which means what |
Student elements take three attributes: "variable", which means what |
it usually does, and "multichoice", which if true allows the user |
it usually does, "multichoice", which if true allows the user |
to select multiple students. |
to select multiple students, and "coursepersonnel" which if true |
|
adds the course personnel to the top of the student selection. |
|
|
=cut |
=cut |
|
|
Line 1807 sub start_student {
|
Line 1808 sub start_student {
|
$paramHash->{'variable'} = $token->[2]{'variable'}; |
$paramHash->{'variable'} = $token->[2]{'variable'}; |
$helper->declareVar($paramHash->{'variable'}); |
$helper->declareVar($paramHash->{'variable'}); |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
$paramHash->{'multichoice'} = $token->[2]{'multichoice'}; |
|
$paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'}; |
if (defined($token->[2]{'nextstate'})) { |
if (defined($token->[2]{'nextstate'})) { |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
} |
} |
Line 1853 BUTTONS
|
Line 1855 BUTTONS
|
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
} |
} |
|
|
# Load up the students |
my $choices = []; |
my $choices = &Apache::loncoursedata::get_classlist(); |
|
my @keys = keys %{$choices}; |
# Load up the non-students, if necessary |
|
if ($self->{'coursepersonnel'}) { |
|
my %coursepersonnel = Apache::lonnet::get_course_adv_roles(); |
|
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 $person (@people) { |
|
push @$choices, [join(':', @$person), $person->[0], '', $_]; |
|
} |
|
} |
|
} |
|
} |
|
|
# Constants |
# Constants |
my $section = Apache::loncoursedata::CL_SECTION(); |
my $section = Apache::loncoursedata::CL_SECTION(); |
my $fullname = Apache::loncoursedata::CL_FULLNAME(); |
my $fullname = Apache::loncoursedata::CL_FULLNAME(); |
|
|
|
# Load up the students |
|
my $classlist = &Apache::loncoursedata::get_classlist(); |
|
my @keys = keys %{$classlist}; |
# Sort by: Section, name |
# Sort by: Section, name |
@keys = sort { |
@keys = sort { |
if ($choices->{$a}->[$section] ne $choices->{$b}->[$section]) { |
if ($classlist->{$a}->[$section] ne $classlist->{$b}->[$section]) { |
return $choices->{$a}->[$section] cmp $choices->{$b}->[$section]; |
return $classlist->{$a}->[$section] cmp $classlist->{$b}->[$section]; |
} |
} |
return $choices->{$a}->[$fullname] cmp $choices->{$b}->[$fullname]; |
return $classlist->{$a}->[$fullname] cmp $classlist->{$b}->[$fullname]; |
} @keys; |
} @keys; |
|
|
|
# username, fullname, section, type |
|
for (@keys) { |
|
push @$choices, [$_, $classlist->{$_}->[$fullname], |
|
$classlist->{$_}->[$section], 'Student']; |
|
} |
|
|
|
my $name = $self->{'coursepersonnel'} ? 'Name' : 'Student Name'; |
my $type = 'radio'; |
my $type = 'radio'; |
if ($self->{'multichoice'}) { $type = 'checkbox'; } |
if ($self->{'multichoice'}) { $type = 'checkbox'; } |
$result .= "<table cellspacing='2' cellpadding='2' border='0'>\n"; |
$result .= "<table cellspacing='2' cellpadding='2' border='0'>\n"; |
$result .= "<tr><td></td><td align='center'><b>Student Name</b></td>". |
$result .= "<tr><td></td><td align='center'><b>$name</b></td>". |
"<td align='center'><b>Section</b></td></tr>"; |
"<td align='center'><b>Section</b></td>" . |
|
"<td align='center'><b>Role</b></td></tr>"; |
|
|
my $checked = 0; |
my $checked = 0; |
foreach (@keys) { |
for my $choice (@$choices) { |
$result .= "<tr><td><input type='$type' name='" . |
$result .= "<tr><td><input type='$type' name='" . |
$self->{'variable'} . '.forminput' . "'"; |
$self->{'variable'} . '.forminput' . "'"; |
|
|
Line 1885 BUTTONS
|
Line 1917 BUTTONS
|
$checked = 1; |
$checked = 1; |
} |
} |
$result .= |
$result .= |
" value='" . HTML::Entities::encode($_ . ':' . $choices->{$_}->[$section]) |
" value='" . HTML::Entities::encode($choice->[0] . ':' . $choice->[2]) |
. "' /></td><td>" |
. "' /></td><td>" |
. HTML::Entities::encode($choices->{$_}->[$fullname]) |
. HTML::Entities::encode($choice->[1]) |
. "</td><td align='center'>" |
. "</td><td align='center'>" |
. HTML::Entities::encode($choices->{$_}->[$section]) |
. HTML::Entities::encode($choice->[2]) |
. "</td></tr>\n"; |
. "</td>\n<td>" |
|
. HTML::Entities::encode($choice->[3]) . "</td></tr>\n"; |
} |
} |
|
|
$result .= "</table>\n\n"; |
$result .= "</table>\n\n"; |