How to follow a specific flow on a questionnaire?

Discussão em 'Angular' iniciado por Devmix, Fevereiro 20, 2025.

  1. Devmix

    Devmix Guest

    I have this questionnaire and I have 3 flows/rules based on what the user selects for answer. I'm displaying the questionnaire using an object called apiData and inside of it I have 2 properties "questions" and "flows". I currently have the first flow working just fine but it seems like the other 2 flows are not working properly.

    Here's a working DEMO Thank you in advance!

    Let me explain the flows:

    1. if user answers question with id 'travel' with the answer that has id "france" and clicks "next" => display question with id "state", then user picks any answer and clicks "next" => display question with id "tolerance", then user picks any answer and clicks "next" display selectedAnswers object.

    and if you look at flow array it's also self-explanatory

    flows: [
    [
    { question: 'travel', answer: 'france' },
    { question: 'state', answer: null },
    { question: 'tolerance', answer: null },
    ],
    ]


    Currently, I'm able to get the First flow working but having an issue with the second and third flow. I also believe the problem is happening here but can't seem to figure it out:

    if (step.answer && answered[step.question] !== step.answer) {
    match = false;
    break;
    }


    Basically, for some reason as soon as I select "Spain" and click on next it prints the selectedAnswer object without following the flow. That's my issue.

    Continue reading...

Compartilhe esta Página