Survey Expressions can now access verbatim values

This commit is contained in:
Patrick Donelan 2009-05-11 06:55:13 +00:00
parent 5f80ac35f6
commit 7a3ecea4bb
2 changed files with 29 additions and 3 deletions

View file

@ -835,11 +835,12 @@ sub responseValuesByVariableName {
# Filter out questions without defined variable names
next if !$question || !defined $question->{variable};
my $answer = $self->survey->answer([@address]);
my $value = $response->{value};
if ($options{useText}) {
# Test if question is a multiple choice type so we can use the answer text instead
if($self->survey->getMultiChoiceBundle($question->{questionType})){
my $answer = $self->survey->answer([@address]);
my $answerText = $answer->{text};
# For verbatim mc answers, combine answer text and recorded value
@ -856,6 +857,17 @@ sub responseValuesByVariableName {
} else {
$lookup{$question->{variable}} = $value;
}
# For verbatims, also add verbatim value to lookup as variable + _verbatim
if ($answer->{verbatim}) {
my $verbatimKey = $question->{variable} . "_verbatim";
my $verbatimValue = $response->{verbatim};
if (!$question->{maxAnswers} || $question->{maxAnswers} > 1) {
push @{$lookup{$verbatimKey}}, $verbatimValue;
} else {
$lookup{$verbatimKey} = $verbatimValue;
}
}
}
return \%lookup;
}