--- loncom/interface/lonhelper.pm 2005/10/11 21:16:37 1.119 +++ loncom/interface/lonhelper.pm 2005/10/17 19:46:12 1.124 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.119 2005/10/11 21:16:37 albertel Exp $ +# $Id: lonhelper.pm,v 1.124 2005/10/17 19:46:12 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1644,13 +1644,15 @@ sub render { $result .= " :\n"; $result .= "\n"; - for my $i ((0,15,30,45,59,undef,1..59)) { + my $selected=0; + for my $i ((0,15,30,45,59,undef,0..59)) { my $printedMinute = $i; if (defined($i) && $i < 10) { $printedMinute = "0" . $printedMinute; } - if ($date->min == $i) { + if (!$selected && $date->min == $i) { $result .= ""; + $selected=1; } else { $result .= ""; } @@ -1659,7 +1661,7 @@ sub render { $result .= "\n"; } if ($self->{'anytime'}) { - $result.=(< // CHECK - $result.=" or {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 $@; + @defaultSymbs = &$valueFunc($helper, $self); + if (!$multichoice) { # only allowed 1 + @defaultSymbs = ($defaultSymbs[0]); + } + } + # 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 @@ -2064,13 +2076,21 @@ BUTTONS } $col .= "symb(); + if (grep(/\Q$symb\E/,@defaultSymbs)) { + $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 . "' />"; @@ -2188,6 +2208,10 @@ selection. Defaults to false. If true, only active students and course personnel will be shown. Defaults to false. +=item * B: + +If true, the selection of no users is allowed. Defaults to false. + =back =cut @@ -2223,6 +2247,7 @@ sub start_student { if (defined($token->[2]{'nextstate'})) { $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; } + $paramHash->{'emptyallowed'} = $token->[2]{'emptyallowed'}; } @@ -2484,9 +2509,14 @@ sub postprocess { my $self = shift; my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; - if (!$result) { - $self->{ERROR_MSG} = - &mt('You must choose at least one student to continue.'); + if (!$result && !$self->{'emptyallowed'}) { + if ($self->{'coursepersonnel'}) { + $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; }