Add support for trigger conditions to remote survey questions #4051
Labels
P0
High priority
QA: Eng
Requires specialized QA by an engineer
Type: Enhancement
Improvement of an existing feature
Milestone
Per requirement for the new Idea Hub survey, we need to make an additional enhancement to the surveys infrastructure itself: Currently it's only possible to show an alternate completion prompt based on an answer to a question. We now need to expand this functionality so that it works for follow-up questions as well.
This is a launch blocker for Idea Hub, even though it's overall a general survey issue.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
question
object includes atrigger_condition
array that is not empty, that question should only be shown if all of the trigger conditions are met.trigger_condition
array can be expected to be exactly the same as for the property of the same name that is already handled for completion prompts. In other words, the logic to handle that can partly be copied, just it should affect the question that it is set on.trigger_condition
entries does not evaluate totrue
based on the answers the current user has given, the question should be skipped and not displayed to the user.question_ordinal
1) will never have any trigger conditions, since there are no answers that could be based on.question_ordinal
, no question will have the same as another, in order to uniquely distinguish them. That means, going forward, for example the question withquestion_ordinal
2 may not necessarily be the second question that is displayed - if it has atrigger_condition
that isn't satisfied, it would be skipped, so that essentially the following question (question_ordinal
3) would be the second question that is displayed.single_select
question as first item with two optionsyes
andno
. There's another question with ordinal 2 that only shows if the user answered the first question withyes
, and also another question with ordinal 3 that only shows if the user answered the second question withyes
.yes
to question 1, question 2 should be shown.yes
to question 2, question 3 should be shown.no
to question 1, both question 2 and 3 should be skipped.Implementation Brief
The API infrastructure is currently being built. Depending on how quickly this gets implemented, the Site Kit Service part may not be ready yet. Please coordinate testing with @felixarntz.
questions
variable created insite-kit-wp/assets/js/components/surveys/CurrentSurvey.js
Lines 66 to 68 in 48e8fe4
trigger_condition
valuetrigger_condition
values that are met by the existing survey data, using thecompletions
variable in the component selected from the data store. Note that eachtrigger_condition
shape will be the same as the conditions incompletions
, seesite-kit-wp/assets/js/components/surveys/__fixtures__/index.js
Lines 20 to 35 in 48e8fe4
questions
topotentialQuestions
then declarequestions
below it based on the filtering described above, so other code can be kept consistent.Test Coverage
assets/js/components/surveys/CurrentSurvey.test.js
to ensure the above described behaviour is working.QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: