Randomly presenting information to each participant using javascript | XM Community
Skip to main content
Hello all,

Apologies if this is the incorrect question category for this topic, but since I have been attempting to tackle the issue using javascript, I figured I could ask here.

I need to be able to present three pieces of information to each survey participant: two strings(each taken from their own lists of related strings) and an image file(taken from a list of image files). For example, I need to show the user one name from a list of names, one occupation from a list of occupations, and one image of a face taken from a collection of images. As it stands, I can do this, but I'm having trouble figuring out how to randomize this so that each participant sees a random combination of names, occupations, and faces from the three different sets of data. I could not find any way to do this in the randomization tools in Qualtrics; I can randomize the place in which name1, occupation1, and face1 appear in the survey, but am unable to have a set consisting of name1, occupation3, and face2 (just as an example). Is there any way I could achieve this through custom code(or if not, through built in Qualtrics tools that I am missing?)

Any advice would be greatly appreciated! If I need to explain anything, restate the question in a different category board, or attach images to help clarify, just let me know.



Thank you!
You can do this with the Randomizer blocks and Block Options. It sounds like you set it up to randomize the first set (the order in which name, occupation and face appear), so in order to randomize all the names, occupations and faces, you'd just set the block options to only show one question:



!



(Edited for clarity)
Thank you, but I don't think I phrased my question correctly, as following your advice didn't solve my problem. Let me try again.

!

The above image shows an example pre-made question, showing the face, name, and occupation. In the actual survey, these need to be pulled from the following fields of example names, etc.:

!

I'm attempting to pull a random item out of each field to populate the survey in the following manner:

!

Is there any method built-in to Qualtrics that would allow me to pull a random item from each field, so that each participant sees a different combination of these items? If not, can I use javascript to do this?

Thank you for your patience and help! Let me know if I need to provide any more details.
Hello @nathillp ,



Assuming you are showing any one image and random data to a respondent.



You can create three Muti choice question for image, name, occupation. In all three questions using default choice option select all options of all question and in advanced randomization set "Randomly insert 1 choices from the list below:" . Now use these questions selected answer pipe in wherever required. Also hide these questions using JS (`jQuery("#"+this.questionId).hide()`)
@Shashi ,

Thank you so much! That worked. Is there any way I can make each survey participant see each name/occupation/image only once during the survey? As these questions rely on randomization and involve multiple trials, I do not want the participants to see the same name, occupation, or image twice in the same survey, if possible.



Thank you again!
> @nathillp said:

> @Shashi ,

> Thank you so much! That worked. Is there any way I can make each survey participant see each name/occupation/image only once during the survey? As these questions rely on randomization and involve multiple trials, I do not want the participants to see the same name, occupation, or image twice in the same survey, if possible.

>

> Thank you again!



In this scenario, we can take help of some JS and set randomly the value of the fields.
@Shashi Would you be able to elaborate on that at all? I am still stuck on this issue.

Thank you
> @nathillp said:

> @Shashi Would you be able to elaborate on that at all? I am still stuck on this issue.

> Thank you



Create 12 Embedded data, three arrays, shuffle the array and set embedded data accordingly.

Leave a Reply