Randomize embedded data with no repetition | XM Community
Solved

Randomize embedded data with no repetition

  • 29 July 2020
  • 2 replies
  • 165 views

Hi all, I want to randomly present 20 pictures, which are randomly paired with 20 sentences. The order for both pictures and sentences are expected to be randomized.
However, if I use loop and merge, the pairing between pictures and sentences will be fixed; if I use embedded data function, The pictures and photos will appear randomly in each iritation so that the same picture/ photo will show up multiple times.
Is there any way I can achieve this? Or any hint on using Javascript to achieve this?
Thank you so much in advance!!!

icon

Best answer by rondev 29 July 2020, 13:36

View original

2 replies

Userlevel 7
Badge +22

Yes, using java script you can create two arrays, then shuffle them and set them to an embedded data.

Userlevel 7
Badge +6

It a bit long to program, but you can do this with the branching logic and randomizer in the survey flow. I'd group all this in a single group block so that it is easy to copy and repeat between each iteration.

Basically you need to create an indicator that a value has been selected by the randomizer, then suppress that option if it was previously selected. You can do this by setting an embedded data indicator a block when the choice is selected and then using branching logic to hide that block when the indicator has been set.
LOL - Having re-written the above paragraph a dozen times, I realize that this is a lot easier to show then to type. Attached is a simple demo of this where it goes through the process 3 times. It wouldn't be that much work to program it to 20.
Demo_-_Randomizing_Embedded_Data_and_Hiding_Once_Shown.qsf

Leave a Reply