--- loncom/interface/lonhelper.pm 2010/03/10 21:25:50 1.179 +++ loncom/interface/lonhelper.pm 2010/05/24 09:21:18 1.180 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.179 2010/03/10 21:25:50 droeschl Exp $ +# $Id: lonhelper.pm,v 1.180 2010/05/24 09:21:18 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3289,6 +3289,10 @@ package Apache::lonhelper::string; string elements provide a string entry field for the user. string elements take the usual 'variable' and 'nextstate' parameters. string elements also pass through 'maxlength' and 'size' attributes to the input tag. +Since you could have multiple strings in a helper state, each with its own +validator, all but the last string should have +noproceed='1' so that _all_ validators are evaluated before the next +state can be reached. string honors the defaultvalue tag, if given. @@ -3308,6 +3312,7 @@ BEGIN { sub new { my $ref = Apache::lonhelper::element->new(); + $ref->{'PROCEED'} = 1; # By default postprocess goes to next state. bless($ref); } @@ -3324,20 +3329,33 @@ sub start_string { $paramHash->{'nextstate'} = $token->[2]{'nextstate'}; $paramHash->{'maxlength'} = $token->[2]{'maxlength'}; $paramHash->{'size'} = $token->[2]{'size'}; - return ''; } sub end_string { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + if ($target ne 'helper') { return ''; } - Apache::lonhelper::string->new(); + my $state = Apache::lonhelper::string->new(); + + + if(&Apache::lonxml::get_param('noproceed', $parstack, $safeeval, undef, 1)) { + $state->noproceed(); + } + + + return ''; } +sub noproceed() { + my $self = shift; + $self->{PROCEED} = 0; +} + sub render { my $self = shift; my $result = ''; @@ -3381,7 +3399,7 @@ sub postprocess { } } - if (defined($self->{'nextstate'})) { + if (defined($self->{'nextstate'}) && $self->{PROCEED}) { $helper->changeState($self->{'nextstate'}); }