Survey Branch Expressions can now test whether a question

has been reached/answered, rather than just testing for the value
of a response
This commit is contained in:
Patrick Donelan 2009-05-04 04:06:40 +00:00
parent 9b72641abb
commit ac1a00b252
3 changed files with 51 additions and 9 deletions

View file

@ -22,7 +22,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 41;
my $tests = 42;
plan tests => $tests + 1;
#----------------------------------------------------------------------------
@ -75,6 +75,7 @@ SKIP: {
q{jump { min(3,5,2) == 2 } target}, # List::Util min
q{jump { sum(value(n),1,1,1) == 8 } target}, # List::Util sum, etc..
q{jump { score(n1) == 1 && score(n2) == 2 } target}, # score() works
q{jump { answered(n) && !answered(X) } target}, # answered() works
);
my @should_fail = (
@ -111,7 +112,6 @@ SKIP: {
is( $e->run( $session, q{jump {1} target}, { values => \%values, validTargets => { target => 1 } } ),
'target', '..whereas now it is ok' );
# Create a test user
$user = WebGUI::User->new( $session, 'new' );
WebGUI::Test->usersToDelete($user);

View file

@ -22,7 +22,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 82;
my $tests = 83;
plan tests => $tests + 1;
#----------------------------------------------------------------------------
@ -432,6 +432,10 @@ $rJSON->nextResponse(2); # pretend we just finished s0q2
$rJSON->processGotoExpression('jump { score("s0") == 300} s1');
is($rJSON->nextResponse, 3, '..and again when section score total used');
$rJSON->nextResponse(2); # pretend we just finished s0q2
$rJSON->processGotoExpression('jump { answered(s0q0) && !answered(ABCDEFG) } s1');
is($rJSON->nextResponse, 3, '..and again when answered() used');
$rJSON->responses({});
$rJSON->questionsAnswered(-1 * $rJSON->questionsAnswered);