Repeating Through A Set of Blocks Multiple Times | XM Community
Skip to main content

Hi,

I have a quiz survey with ChatGPT integration. At the start of the quiz I have 5 hard coded questions the user will answer. After these 5 questions, I want to ask if the user would like an additional question or to finish the survey. If they chose additional question, I want to send them through 3 blocks that use the ChatGPT API to create a new question, which I already have set up. Once they complete this question, I want to again ask them if they would like an additional question or to finish the survey. I want this process to repeat as many times as the user wants, and only finishing the survey when they click the “finish survey” option. How can I accomplish this? I am having a hard time understanding if loop & merge can accomplish this.

Thank you

@StephenFief You should achieve this by:

  1. Adding loop and merge to loop 3 times the relevant question plus the question where you ask if they want another one - they must be placed in the same block and you can e.g., add static logic by adding a value for 3 rows in the „Field 1“ column (e.g., 1, 2 and 3)
  2. Define some embedded data „Exit“ before the loop and merge block which is set to 0
  3. Add some display logic to the questions inside the Loop which only shows both questions if „Exit“ is 0
  4. Add some JavaScript to the question where you ask if they want another question which sets „Exit“ to 1 if they do not want another question
  5. You may also want to define some display logic to not show the „Do you want another question?“ question in the third iteration

JavaScript is probably something like this if „No“ is the 2nd choice in a multiple choice question:

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
    var SelectedChoices = this.getSelectedChoices();
    if(SelectedChoices == 2) {
Qualtrics.SurveyEngine.setEmbeddedData(“Exit", 1);
}

Best

Christian


@StephenFief You should achieve this by:

  1. Adding loop and merge to loop 3 times the relevant question plus the question where you ask if they want another one - they must be placed in the same block and you can e.g., add static logic by adding a value for 3 rows in the „Field 1“ column (e.g., 1, 2 and 3)
  2. Define some embedded data „Exit“ before the loop and merge block which is set to 0
  3. Add some display logic to the questions inside the Loop which only shows both questions if „Exit“ is 0
  4. Add some JavaScript to the question where you ask if they want another question which sets „Exit“ to 1 if they do not want another question
  5. You may also want to define some display logic to not show the „Do you want another question?“ question in the third iteration

JavaScript is probably something like this if „No“ is the 2nd choice in a multiple choice question:

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
    var SelectedChoices = this.getSelectedChoices();
    if(SelectedChoices == 2) {
Qualtrics.SurveyEngine.setEmbeddedData(“Exit", 1);
}

Best

Christian

I need 3 separate blocks for this section of my quiz though, not all in one block, due to the web service call and javascript editing. Is that not possible with 3 blocks wanting to act like 1 block?


@StephenFief Mhhh, the issue is that the loop & merge works block-based and you will need to run through all iterations of the first block before you can start with the next block. So this will not work…

Let me think again about it…


@StephenFief Mhhh, the issue is that the loop & merge works block-based and you will need to run through all iterations of the first block before you can start with the next block. So this will not work…

Let me think again about it…

I am thinking this is not possible in Qualtrics. For version 1 of this quiz I may limit the amount of additional questions to 5 and manually create the logic rather than a genuine loop. Sounds like a python project for version 2.


Please check this demo.

 


Please check this demo.

 

That is what I am trying to get to, but that video doesn’t help any


Leave a Reply