Skip to content

Feature request: An easier way to include answers from previous questions in later questions #136

Closed
@mgd722

Description

@mgd722

Is your feature request related to a problem? Please describe.
Often, later questions in the survey depend on answers from previous questions. Example:

  1. What is your favorite food?
    <QuestionType.Text>

  2. What is your second favorite food?
    <QuestionType.Text>

  3. Which of your favorite foods is saltier?
    <QuestionType.MultipleChoice>
    <ChoiceOption answer_1>
    <ChoiceOption answer_2>

Describe alternatives you've considered
Currently I have my questions array as a computed property that can update question choices based on listening to previous answers. This is awkward and not very robust. I have to iterate through the questions array, find the question with a given id that I'm looking for, get the answer, do the same thing for the second question, then find the question I want to update, and finally create a new array of ChoiceOption objects for it. It works but it feels hacky and way more verbose than it should be.

Describe the solution you'd like
There should be some easy way to rely on answers from previous questions. The current system of instantiating a new ChoiceOption in the component's data object makes this difficult. After reviewing the source code, I think allowing developers to pass flow-form-questions directly to the flow-form component as a slot would allow for the most extensibility and would be most Vue-like. Developers could still use the existing data-based method of passing questions if they wanted, but an option for something like this would be very powerful and (in my opinion) easier for devs to create different question tracks as well:

<flow-form
    // ...your regular flowform options
>
    <question
        v-model="favoriteFood"
        type="Text"
        // ...include any other QuestionModel parameters
    />
    <question
        v-model="secondFavoriteFood"
        type="Text"
    />
    <question
        v-model="saltierFood"
        type="MultipleChoice"
        :options="{label: favoriteFood}, {label: secondFavoriteFood}"
    />
</flow-form>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions