How to randomly select 3 items without replacement, and embed them in different survey stages? | XM Community
Skip to main content
Solved

How to randomly select 3 items without replacement, and embed them in different survey stages?

  • June 26, 2020
  • 5 replies
  • 165 views

Forum|alt.badge.img

I want to randomly select 3 images out of 100+ images, and embed them in different questions throughout the survey. It is crucial that every single respondent will not see the same image twice (randomizing without replacement), for example, respondent A can see images 1, 2, 3 but not images 1, 1, 2. What is the best way to do this? the number of questions after each image varies (and is actually conditioned on other questions previously answered using display logic).

Best answer by rondev

The JS written here, stores the image url into three different embedded data i.e. firstPicture, secondPicture, thirdPicture. Then you just need to pipe these embedded data into the img tag src as ->

Make sure you declare those three embedded data in the survey flow at the very start of flow.

5 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • June 26, 2020

Same post here


Forum|alt.badge.img
  • Author
  • June 26, 2020

https://www.qualtrics.com/community/discussion/comment/27257#Comment_27257thanks rondev , not exactly though. I would like to take each of these images and embed them in different places in the survey individually (not as 3 images)


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • June 26, 2020

The JS written here, stores the image url into three different embedded data i.e. firstPicture, secondPicture, thirdPicture. Then you just need to pipe these embedded data into the img tag src as ->

Make sure you declare those three embedded data in the survey flow at the very start of flow.


Forum|alt.badge.img
  • Author
  • June 26, 2020

Forum|alt.badge.img
  • Author
  • June 28, 2020

rondev or SurajK do you know how I can view each of the variables (firstPicture, secondPicture...) when I export my dataset? I created three embedded data variables with those names, but they don't record which image each respondent was assigned (they just appear as blank variables).