diff --git a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm index c2a76ebb6..d2fb38395 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm @@ -297,7 +297,15 @@ sub currentSection { #------------------------------------------------------------------- -=head2 recordResponses +=head2 recordResponses ($session, $responses) + +=head3 $session + +A WebGUI session object + +=head3 $responses + +A hash ref. More news at 6 o'clock. =cut @@ -337,7 +345,7 @@ sub recordResponses { #There were no questions in the section just displayed, so increment the lastResponse by one if ( ref $questions ne 'ARRAY' ) { $self->lastResponse( $self->lastResponse + 1 ); - return [ $terminal, $terminalUrl ]; + return [ $sterminal, $terminalUrl ]; } for my $question (@$questions) { diff --git a/t/Asset/Wobject/Survey/ResponseJSON.t b/t/Asset/Wobject/Survey/ResponseJSON.t index 8f41a3811..43cc27563 100644 --- a/t/Asset/Wobject/Survey/ResponseJSON.t +++ b/t/Asset/Wobject/Survey/ResponseJSON.t @@ -20,7 +20,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 41; +my $tests = 44; plan tests => $tests + 1; #---------------------------------------------------------------------------- @@ -319,6 +319,31 @@ is($rJSON->lastResponse(), 0, 'goto: works on existing question'); $rJSON->goto('goto 3-0'); is($rJSON->lastResponse(), 5, 'goto: finds first if there are duplicates'); +#################################################### +# +# recordResponses +# +#################################################### + +$rJSON->lastResponse(4); +my $terminals; +cmp_deeply( + $rJSON->recordResponses($session, {}), + [ 0, undef ], + 'recordResponses, if section has no questions, returns terminal info in the section. With no terminal info, returns [0, undef]', +); +is($rJSON->lastResponse(), 5, 'recordResponses, increments lastResponse if there are no questions in the section'); + +$rJSON->survey->section([2])->{terminal} = 1; +$rJSON->survey->section([2])->{terminalUrl} = '/terminal'; + +$rJSON->lastResponse(4); +cmp_deeply( + $rJSON->recordResponses($session, {}), + [ 1, '/terminal' ], + 'recordResponses, if section has no questions, returns terminal info in the section.', +); + } ####################################################