version 1.122, 2005/10/11 22:05:20
|
version 1.126, 2005/10/17 21:14:55
|
Line 2017 BUTTONS
|
Line 2017 BUTTONS
|
$mapUrl = $self->{MAP_URL}; |
$mapUrl = $self->{MAP_URL}; |
} |
} |
|
|
|
my %defaultSymbs; |
|
if (defined($self->{DEFAULT_VALUE})) { |
|
my $valueFunc = eval($self->{DEFAULT_VALUE}); |
|
die 'Error in default value code for variable ' . |
|
$self->{'variable'} . ', Perl said: ' . $@ if $@; |
|
my @defaultSymbs = &$valueFunc($helper, $self); |
|
if (!$multichoice && @defaultSymbs) { # only allowed 1 |
|
@defaultSymbs = ($defaultSymbs[0]); |
|
} |
|
%defaultSymbs = map { if ($_) {($_,1) } } @defaultSymbs; |
|
delete($defaultSymbs{''}); |
|
} |
|
|
# Create the composite function that renders the column on the nav map |
# Create the composite function that renders the column on the nav map |
# have to admit any language that lets me do this can't be all bad |
# have to admit any language that lets me do this can't be all bad |
Line 2065 BUTTONS
|
Line 2077 BUTTONS
|
} |
} |
|
|
$col .= "<td align='center'><input type='$inputType' name='${var}.forminput' "; |
$col .= "<td align='center'><input type='$inputType' name='${var}.forminput' "; |
if (!$checked && !$multichoice) { |
if (%defaultSymbs) { |
$col .= "checked='checked' "; |
my $symb=$resource->symb(); |
$checked = 1; |
if (exists($defaultSymbs{$symb})) { |
} |
$col .= "checked='checked' "; |
if ($multichoice) { # all resources start checked; see bug 1174 |
$checked = 1; |
$col .= "checked='checked' "; |
} |
$checked = 1; |
} else { |
|
if (!$checked && !$multichoice) { |
|
$col .= "checked='checked' "; |
|
$checked = 1; |
|
} |
|
if ($multichoice) { # all resources start checked; see bug 1174 |
|
$col .= "checked='checked' "; |
|
$checked = 1; |
|
} |
} |
} |
$col .= "value='" . $resource_name . "' /></td>"; |
$col .= "value='" . $resource_name . "' /></td>"; |
|
|
Line 2189 selection. Defaults to false.
|
Line 2209 selection. Defaults to false.
|
If true, only active students and course personnel will be |
If true, only active students and course personnel will be |
shown. Defaults to false. |
shown. Defaults to false. |
|
|
|
=item * B<emptyallowed>: |
|
|
|
If true, the selection of no users is allowed. Defaults to false. |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2224 sub start_student {
|
Line 2248 sub start_student {
|
if (defined($token->[2]{'nextstate'})) { |
if (defined($token->[2]{'nextstate'})) { |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
$paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; |
} |
} |
|
$paramHash->{'emptyallowed'} = $token->[2]{'emptyallowed'}; |
|
|
} |
} |
|
|
Line 2345 BUTTONS
|
Line 2370 BUTTONS
|
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
$result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />'; |
} |
} |
|
|
|
my %defaultUsers; |
|
if (defined($self->{DEFAULT_VALUE})) { |
|
my $valueFunc = eval($self->{DEFAULT_VALUE}); |
|
die 'Error in default value code for variable ' . |
|
$self->{'variable'} . ', Perl said: ' . $@ if $@; |
|
my @defaultUsers = &$valueFunc($helper, $self); |
|
if (!$self->{'multichoice'} && @defaultUsers) { # only allowed 1 |
|
@defaultUsers = ($defaultUsers[0]); |
|
} |
|
%defaultUsers = map { if ($_) {($_,1) } } @defaultUsers; |
|
delete($defaultUsers{''}); |
|
} |
my $choices = []; |
my $choices = []; |
|
|
# Load up the non-students, if necessary |
# Load up the non-students, if necessary |
Line 2410 BUTTONS
|
Line 2447 BUTTONS
|
$result .= "<tr><td><input type='$type' name='" . |
$result .= "<tr><td><input type='$type' name='" . |
$self->{'variable'} . '.forminput' . "'"; |
$self->{'variable'} . '.forminput' . "'"; |
|
|
if (!$self->{'multichoice'} && !$checked) { |
if (%defaultUsers) { |
|
my $user=$choice->[0]; |
|
if (exists($defaultUsers{$user})) { |
|
$result .= " checked='checked' "; |
|
$checked = 1; |
|
} |
|
} elsif (!$self->{'multichoice'} && !$checked) { |
$result .= " checked='checked' "; |
$result .= " checked='checked' "; |
$checked = 1; |
$checked = 1; |
} |
} |
Line 2485 sub postprocess {
|
Line 2528 sub postprocess {
|
my $self = shift; |
my $self = shift; |
|
|
my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; |
my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; |
if (!$result) { |
if (!$result && !$self->{'emptyallowed'}) { |
$self->{ERROR_MSG} = |
if ($self->{'coursepersonnel'}) { |
&mt('You must choose at least one student to continue.'); |
$self->{ERROR_MSG} = |
|
&mt('You must choose at least one user to continue.'); |
|
} else { |
|
$self->{ERROR_MSG} = |
|
&mt('You must choose at least one student to continue.'); |
|
} |
return 0; |
return 0; |
} |
} |
|
|