diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0c9bc1649..c301a3a41 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.7.4 - Default Survey Question bundles now store full answer information in json. Everything configured in an answer will be saved in a default configuration. + - Survey [[question variable]] now returns the shown answer text for multiple choice questions, and the recorded value for non-multiple choice questions. 7.7.3 - fixed #10094: double explanation in thread help diff --git a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm index 16723a63e..2a7f2d014 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm @@ -738,12 +738,18 @@ sub responseValuesByVariableName { # Grab the corresponding question my $question = $self->survey->question([@address]); - + # Filter out questions without defined variable names next if !$question || !defined $question->{variable}; + #Test if question is a multiple choice type so we can use the answer text instead + my $answerText; + if($self->survey->getMultiChoiceBundle($question->{questionType})){ + $answerText = $self->survey->answer([@address])->{text}; + } + # Add variable => value to our hash - $lookup{$question->{variable}} = $response->{value}; + $lookup{$question->{variable}} = $answerText ? $answerText : $response->{value}; } return \%lookup; } diff --git a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm index 5b074ecfd..0b4e8896f 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm @@ -998,9 +998,7 @@ sub updateQuestionAnswers { =head2 getMultiChoiceBundle -Returns a list of answers for each multi-choice bundle. - -Currently these are hard-coded but soon they will live in the database. +Returns a list of answer objects for each multi-choice bundle. =cut