Embedded data and Loop&Merge and Randomisation: selected options on every loop | XM Community
Question

Embedded data and Loop&Merge and Randomisation: selected options on every loop

  • 16 March 2021
  • 1 reply
  • 29 views

Userlevel 7
Badge +23
  • Level 5 ●●●●●
  • 449 replies

Hi all,
I have been struggling with embedded data vs Merge&Loop and Randomisation. I hope you can help me :)

The setup we have is like a maxdiff (we do not have it in license, so had to improvise):
1 Question with 10 options:
image.png
There is a randomiser set up for this question to randomly and equally present subset of 4 choices out of these 10:
image.png
The question is on the loop & merge, to randomly present 7 loops:
image.png
The goal for me is to have an embedded data that will record which option was selected as "Least", which option was selected as "Most" for each loop; and what is the total number each option has been presented ( we want to build a formula out of these three).
Unfortunately this question type is not supported by Scoring, which makes my life somewhat difficult at the moment..

Please help!


1 reply

Userlevel 7
Badge +21

Capturing the number of times an option is presented is easy.
Qualtrics.SurveyEngine.addOnReady(function () {
    let qc = quest.questionContainer;
    let choice_obj = {
        // Fill up the values here in the format "choice_number": "text_of_choice_number",
        choice_1: "1",
        choice_2: "2",
    };
    let choices_displayed = [];
    qc.querySelectorAll(".LabelWrapper").forEach((ch) => choices_displayed.push(ch.innerText));
    Object.keys(choice_obj).forEach((choice) => {
        if (choices_displayed.indexOf(choice_obj[choice]) > -1) {
            let displ = Number(Qualtrics.SurveyEngine.getEmbeddedData(choice));
            if (isNaN(displ)) {
                displ = 1;
            } else {
                displ++;
            }
            Qualtrics.SurveyEngine.setEmbeddedData(choice, displ);
        }
    });
});

If you add this JS to your question, it will create 10 embedded data fields, "choice_1" to "choice_10". These will store the number of times each choice has been displayed.
I'm a little confused about the Least and Most, because that's basically the answer you get from MaxDiff. One of the 10 will be least and one of the 10 will be most.
Aren't you getting this in your data?

Leave a Reply