version 1.128, 2005/11/22 12:49:50
|
version 1.132, 2006/03/06 23:32:31
|
Line 576 sub display {
|
Line 576 sub display {
|
my $html=&Apache::lonxml::xmlbegin(); |
my $html=&Apache::lonxml::xmlbegin(); |
my $stateTitle=&mt($state->title()); |
my $stateTitle=&mt($state->title()); |
my $helperTitle = &mt($self->{TITLE}); |
my $helperTitle = &mt($self->{TITLE}); |
|
my $browser_searcher_js = &Apache::loncommon::browser_and_searcher_javascript(); |
my $bodytag = &Apache::loncommon::bodytag($helperTitle,'',''); |
my $bodytag = &Apache::loncommon::bodytag($helperTitle,'',''); |
my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); |
my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); |
Line 586 sub display {
|
Line 587 sub display {
|
$html |
$html |
<head> |
<head> |
<title>$loncapaHelper: $helperTitle</title> |
<title>$loncapaHelper: $helperTitle</title> |
|
<script type="text/javascript"> |
|
$browser_searcher_js |
|
</script> |
</head> |
</head> |
$bodytag |
$bodytag |
HEADER |
HEADER |
Line 1557 sub render {
|
Line 1561 sub render {
|
my $date; |
my $date; |
|
|
my $time=time; |
my $time=time; |
|
$date = localtime($time); |
|
$date->min(0); |
my ($anytime,$onclick); |
my ($anytime,$onclick); |
|
|
if (defined($self->{DEFAULT_VALUE})) { |
if (defined($self->{DEFAULT_VALUE})) { |
Line 1564 sub render {
|
Line 1570 sub render {
|
die('Error in default value code for variable ' . |
die('Error in default value code for variable ' . |
$self->{'variable'} . ', Perl said: ' . $@) if $@; |
$self->{'variable'} . ', Perl said: ' . $@) if $@; |
$time = &$valueFunc($helper, $self); |
$time = &$valueFunc($helper, $self); |
if (lc($time) eq 'anytime') { $time=time; $anytime=1; } |
if (lc($time) eq 'anytime') { |
|
$anytime=1; |
|
} else { |
|
$date = localtime($time); |
|
} |
|
} else { |
|
|
} |
} |
if ($anytime) { |
if ($anytime) { |
$onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\""; |
$onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\""; |
} |
} |
# Default date: The current hour. |
# Default date: The current hour. |
$date = localtime($time); |
|
$date->min(0); |
|
|
|
if (defined $self->{ERROR_MSG}) { |
if (defined $self->{ERROR_MSG}) { |
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
Line 2296 sub render {
|
Line 2306 sub render {
|
} |
} |
} |
} |
} |
} |
|
function checkexpired() { |
|
for (i=0; i<document.forms.helpform.elements.length; i++) { |
|
if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) { |
|
document.forms.helpform.elements[i].checked=true; |
|
} |
|
} |
|
} |
function uncheckexpired() { |
function uncheckexpired() { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) { |
if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) { |
Line 2364 SCRIPT
|
Line 2381 SCRIPT
|
</table> |
</table> |
<br /> |
<br /> |
BUTTONS |
BUTTONS |
|
$result .= $buttons; |
|
|
} |
} |
|
|
if (defined $self->{ERROR_MSG}) { |
if (defined $self->{ERROR_MSG}) { |
Line 2383 BUTTONS
|
Line 2402 BUTTONS
|
delete($defaultUsers{''}); |
delete($defaultUsers{''}); |
} |
} |
my $choices = []; |
my $choices = []; |
|
my $expired_students = []; # Will hold expired students. |
|
|
# Load up the non-students, if necessary |
# Load up the non-students, if necessary |
if ($self->{'coursepersonnel'}) { |
if ($self->{'coursepersonnel'}) { |
Line 2420 BUTTONS
|
Line 2440 BUTTONS
|
} |
} |
return $classlist->{$a}->[$fullname] cmp $classlist->{$b}->[$fullname]; |
return $classlist->{$a}->[$fullname] cmp $classlist->{$b}->[$fullname]; |
} @keys; |
} @keys; |
|
# |
|
# now add the fancy section choice... first enumerate the sections: |
|
if ($self->{'multichoice'}) { |
|
my %sections; |
|
for my $key (@keys) { |
|
my $section_name = $classlist->{$key}->[$section]; |
|
if ($section_name ne "") { |
|
$sections{$section_name} = 1; |
|
} |
|
} |
|
# The variable $choice_widget will have the html to make the choice |
|
# selector. |
|
my $size=5; |
|
if (scalar(keys(%sections)) < 5) { |
|
$size=scalar(keys(%sections)); |
|
} |
|
my $choice_widget = '<select multiple name="chosensections" size="'.$size.'">'."\n"; |
|
foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) { |
|
$choice_widget .= "<option name=\"$sec\">$sec</option>\n"; |
|
} |
|
$choice_widget .= "<option>none</option></select>\n"; |
|
|
|
# Build a table without any borders to contain the section based |
|
# selection: |
|
|
|
my $section_selectors =<<SECTIONSELECT; |
|
<table border="0"> |
|
<tr valign="top"> |
|
<td>For Sections:</td><td>$choice_widget</td> |
|
<td><label><input type="radio" name="personstate" value="Active" checked /> |
|
Current Students</label></td> |
|
<td><label><input type="radio" name="personstate" value="All" /> |
|
All students</label></td> |
|
<td><label><input type="radio" name="personstate" value="Expired" /> |
|
Expired Students</label></td> |
|
</tr> |
|
<tr> |
|
<td><input type="button" value="Select" onclick="checksections(true);" /></td> |
|
<td><input type="button" value="Unselect" onclick="checksections(false);" /></td></tr> |
|
</table> |
|
<br /> |
|
SECTIONSELECT |
|
$result .= $section_selectors; |
|
} |
|
|
# username, fullname, section, type |
# username, fullname, section, type |
for (@keys) { |
for (@keys) { |
# Filter out inactive students if we've set "activeonly" |
|
if (!$self->{'activeonly'} || $classlist->{$_}->[$status] eq |
# We split the active students into the choices array and |
|
# inactive ones into expired_students so that we can put them in 2 separate |
|
# tables. |
|
|
|
if ( $classlist->{$_}->[$status] eq |
'Active') { |
'Active') { |
push @$choices, [$_, $classlist->{$_}->[$fullname], |
push @$choices, [$_, $classlist->{$_}->[$fullname], |
$classlist->{$_}->[$section], |
$classlist->{$_}->[$section], |
$classlist->{$_}->[$status], 'Student']; |
$classlist->{$_}->[$status], 'Student']; |
|
} else { |
|
push @$expired_students, [$_, $classlist->{$_}->[$fullname], |
|
$classlist->{$_}->[$section], |
|
$classlist->{$_}->[$status], 'Student']; |
} |
} |
} |
} |
|
|
Line 2443 BUTTONS
|
Line 2515 BUTTONS
|
"<td align='center'><b>".&mt('Username').":".&mt('Domain')."</b></td></tr>"; |
"<td align='center'><b>".&mt('Username').":".&mt('Domain')."</b></td></tr>"; |
|
|
my $checked = 0; |
my $checked = 0; |
|
# |
|
# Give the active students and staff: |
|
# |
for my $choice (@$choices) { |
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 2474 BUTTONS
|
Line 2549 BUTTONS
|
. HTML::Entities::encode($choice->[0],'<>&"') |
. HTML::Entities::encode($choice->[0],'<>&"') |
. "</td></tr>\n"; |
. "</td></tr>\n"; |
} |
} |
|
|
$result .= "</table>\n\n"; |
$result .= "</table>\n\n"; |
$result .= $buttons; |
|
|
# If activeonly is not set then we can also give the expired students: |
# |
# |
# now add the fancy section choice... first enumerate the sections: |
if (!$self->{'activeonly'} && ((scalar @$expired_students) > 0)) { |
if ($self->{'multichoice'}) { |
$result .= "<p>Inactive students: </p>\n"; |
my %sections; |
$result .= <<INACTIVEBUTTONS; |
for my $key (@keys) { |
<table> |
my $section_name = $classlist->{$key}->[$section]; |
<tr> |
if ($section_name ne "") { |
<td><input type="button" value="Select expired" onclick="checkexpired();" /> </td> |
$sections{$section_name} = 1; |
<td><input type="button" value="Unselect expired" onclick="uncheckexpired();" /></td> |
|
</tr> |
|
</table> |
|
INACTIVEBUTTONS |
|
$result .= "<table>\n"; |
|
|
|
for my $choice (@$expired_students) { |
|
$result .= "<tr><td><input type='$type' name='" . |
|
$self->{'variable'} . '.forminput' . "'"; |
|
|
|
if (%defaultUsers) { |
|
my $user=$choice->[0]; |
|
if (exists($defaultUsers{$user})) { |
|
$result .= " checked='checked' "; |
|
$checked = 1; |
} |
} |
|
} elsif (!$self->{'multichoice'} && !$checked) { |
|
$result .= " checked='checked' "; |
|
$checked = 1; |
|
} |
|
$result .= |
|
" value='" . HTML::Entities::encode($choice->[0] . ':' |
|
.$choice->[2] . ':' |
|
.$choice->[1] . ':' |
|
.$choice->[3], "<>&\"'") |
|
. "' /></td><td>" |
|
. HTML::Entities::encode($choice->[1],'<>&"') |
|
. "</td><td align='center'>" |
|
. HTML::Entities::encode($choice->[2],'<>&"') |
|
. "</td>\n<td>" |
|
. HTML::Entities::encode($choice->[3],'<>&"') |
|
. "</td>\n<td>" |
|
. HTML::Entities::encode($choice->[4],'<>&"') |
|
. "</td>\n<td>" |
|
. HTML::Entities::encode($choice->[0],'<>&"') |
|
. "</td></tr>\n"; |
} |
} |
# The variable $choice_widget will have the html to make the choice |
$result .= "</table>\n"; |
# selector. |
|
my $size=5; |
} |
if (scalar(keys(%sections)) < 5) { |
|
$size=scalar(keys(%sections)); |
|
} |
|
my $choice_widget = '<select multiple name="chosensections" size="'.$size.'">'."\n"; |
|
foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) { |
|
$choice_widget .= "<option name=\"$sec\">$sec</option>\n"; |
|
} |
|
$choice_widget .= "<option>none</option></select>\n"; |
|
|
|
# Build a table without any borders to contain the section based |
|
# selection: |
|
|
|
my $section_selectors =<<SECTIONSELECT; |
|
<table border="0"> |
|
<tr valign="top"> |
|
<td>For Sections:</td><td>$choice_widget</td> |
|
<td><label><input type="radio" name="personstate" value="Active" checked /> |
|
Current Students</label></td> |
|
<td><label><input type="radio" name="personstate" value="All" /> |
|
All students</label></td> |
|
<td><label><input type="radio" name="personstate" value="Expired" /> |
|
Expired Students</label></td> |
|
</tr> |
|
<tr> |
|
<td><input type="button" value="Select" onclick="checksections(true);" /></td> |
|
<td><input type="button" value="Unselect" onclick="checksections(false);" /></td></tr> |
|
</table> |
|
<br /> |
|
SECTIONSELECT |
|
$result .= $section_selectors; |
|
} |
|
return $result; |
return $result; |
} |
} |
|
|