Survey: fixed subtle bug in testing of answers with recordedAnswer set to q{}

This commit is contained in:
Patrick Donelan 2009-05-21 08:21:54 +00:00
parent d246454b2f
commit f55559e124
2 changed files with 6 additions and 7 deletions

View file

@ -306,7 +306,7 @@ sub _test {
return fail($testCount, "determine answer for $variable", "No answers matched text: '$spec'"); return fail($testCount, "determine answer for $variable", "No answers matched text: '$spec'");
} }
$self->session->log->debug("Recording $variable ($answerAddress) => $answer->{recordedAnswer}"); $self->session->log->debug("Recording $variable ($answerAddress) => $answer->{recordedAnswer}");
$responses->{$answerAddress} = $answer->{recordedAnswer}; $responses->{$answerAddress} = 1;
} }
} }
@ -444,8 +444,7 @@ sub _test_mc {
my $answerAddress = "$address->[0]-$address->[1]-$aIndex"; my $answerAddress = "$address->[0]-$address->[1]-$aIndex";
my $answer = $answers->[$aIndex]; my $answer = $answers->[$aIndex];
my $recordedAnswer = $answer->{recordedAnswer}; $responses->{$answerAddress} = 1;
$responses->{$answerAddress} = $recordedAnswer;
my $name = $opts{name}; # get this fresh for every subtest my $name = $opts{name}; # get this fresh for every subtest
if ($name) { if ($name) {
@ -458,7 +457,7 @@ sub _test_mc {
$name .= " for $variable mc answer " . ($aIndex + 1); $name .= " for $variable mc answer " . ($aIndex + 1);
} }
$self->session->log->debug("Recording answer for mc question $variable at index $aIndex ($answerAddress) => $recordedAnswer"); $self->session->log->debug("Choosing mc question $variable answer index $aIndex ($answerAddress)");
push @tap, $self->_recordResponses( { push @tap, $self->_recordResponses( {
responseJSON => $rJSON, responseJSON => $rJSON,
responses => $responses, responses => $responses,

View file

@ -83,8 +83,8 @@ $s->surveyJSON_update( [ 0, 0 ], { questionType => 'Yes/No' } ); # S0Q0 is a Yes
$s->surveyJSON_update( [ 0, 0 ], { gotoExpression => q{ tag('tagged at S0Q0'); } } ); # S0Q0 tagged data $s->surveyJSON_update( [ 0, 0 ], { gotoExpression => q{ tag('tagged at S0Q0'); } } ); # S0Q0 tagged data
$s->surveyJSON_update( [ 1, 0 ], { questionType => 'Yes/No' } ); # S1Q0 is a Yes/No $s->surveyJSON_update( [ 1, 0 ], { questionType => 'Yes/No' } ); # S1Q0 is a Yes/No
$s->surveyJSON_update( [ 1, 0, 0 ], { goto => 'S3' } ); # S1Q0 answer 0 jumps to S3 $s->surveyJSON_update( [ 1, 0, 0 ], { goto => 'S3', recordedAnswer => q{} } ); # S1Q0 answer 0 jumps to S3 (set recordedAnswer to '' to detect subtle bug)
$s->surveyJSON_update( [ 1, 0, 1 ], { gotoExpression => q{ tag('tagged at S1Q0', 999); } } );# S1Q0 answer 1 tagged numeric data $s->surveyJSON_update( [ 1, 0, 1 ], { gotoExpression => q{ tag('tagged at S1Q0', 999); }, recordedAnswer => q{} } );# S1Q0 answer 1 tagged numeric data
$s->surveyJSON_update( [ 3 ], { gotoExpression => q{ jump { score(S3) == 0 } S5; } } ); # jump to S5 if all 3 questions answered as No $s->surveyJSON_update( [ 3 ], { gotoExpression => q{ jump { score(S3) == 0 } S5; } } ); # jump to S5 if all 3 questions answered as No
for my $qIndex (0..2) { for my $qIndex (0..2) {
@ -596,7 +596,7 @@ $spec = <<END_SPEC;
[ [
{ {
"sequence" : { "sequence" : {
"S1Q0" : { "recordedAnswer" : "desc", "score" : "cons" }, # This is a default Yes/No (score all 1) "S0Q0" : { "recordedAnswer" : "desc", "score" : "cons" }, # This is a default Yes/No (score all 1)
"S4Q0" : { "recordedAnswer" : "asc" }, # Certainty scale, with recordedAnswer 0 .. 11 "S4Q0" : { "recordedAnswer" : "asc" }, # Certainty scale, with recordedAnswer 0 .. 11
"S3Q0" : { "recordedAnswer" : "desc", "score" : "desc" }, # These 3 are yes/no questions where we have "S3Q0" : { "recordedAnswer" : "desc", "score" : "desc" }, # These 3 are yes/no questions where we have
"S3Q1" : { "recordedAnswer" : "desc", "score" : "desc" }, # ..set the score on the No answer to zero, hence "S3Q1" : { "recordedAnswer" : "desc", "score" : "desc" }, # ..set the score on the No answer to zero, hence