--- loncom/interface/lonhelper.pm 2003/05/08 19:52:43 1.25 +++ loncom/interface/lonhelper.pm 2003/05/08 20:10:49 1.26 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.25 2003/05/08 19:52:43 bowersj2 Exp $ +# $Id: lonhelper.pm,v 1.26 2003/05/08 20:10:49 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -960,6 +960,10 @@ the result is stored in. takes an attribute "multichoice" which, if set to a true value, will allow the user to select multiple choices. + takes an attribute "allowempty" which, if set to a true +value, will allow the user to select none of the choices without raising +an error message. + B can have the following subtags: @@ -1049,6 +1053,7 @@ sub start_choices { $paramHash->{'variable'} = $token->[2]{'variable'} if (!defined($paramHash->{'variable'})); $helper->declareVar($paramHash->{'variable'}); $paramHash->{'multichoice'} = $token->[2]{'multichoice'}; + $paramHash->{'allowempty'} = $token->[2]{'allowempty'}; $paramHash->{CHOICES} = []; return ''; } @@ -1193,7 +1198,7 @@ sub postprocess { my $self = shift; my $chosenValue = $ENV{'form.' . $self->{'variable'} . '.forminput'}; - if (!defined($chosenValue)) { + if (!defined($chosenValue) && !$self->{'allowempty'}) { $self->{ERROR_MSG} = "You must choose one or more choices to" . " continue."; return 0;