Randomize order of fields within a loop & merge row (JS?) | XM Community
Skip to main content

Hi community! Here's a scaled-down version of what I need:
Set-up: We're rolling 6-sided dice to determine payouts. Participants see 3 Scenarios. Each scenario will be displayed one-at-a-time in tables like these:
all scenarios - updated.pngNeed: I need to randomize along two dimensions: (1) The order that the Scenarios are presented to participants (e.g., sometimes the order is A-C-B sometimes it's C-B-A, etc.) & (2) the dice numbers that are winners (e.g., for Scenario B, sometimes the $10 payouts occur if you roll a 2, 3, or 6 and sometimes they occur if you roll a 1, 4, or 5, etc.).
Attempted: Right now I have loop & merge set up where each row of the L&M table corresponds to a different Scenario and I select the option to randomize the order that rows are displayed. However I have manually coded the L&M table so that for Scenario A : Field 1 = $10, Fields 2-6 = $0; for Scenario B: Fields 1-3 = $10, Fields 4-6 = $0; for Scenario C: Fields 1-4 = $10, Fields 5-6 = $0).
Problem: This fixes the "roll of the dice" numbers that corresponding to winning $10 or $0. I need to randomize that. What I need is a way to randomize the order of fields too!
I think I could accomplish this by having a separate block for each Scenario, using L&M within each block, and then using a Randomizer (in the Survey Flow) to randomize the order of the scenarios. But this isn't viable for me because the above is just a tiny example--in fact I have 50 different scenarios (each scenarios randomizes 1-100, not 1-12). So it's not practical for me to create 50 different blocks, 1 per scenario (for instance, if I need to make a small tweak to one question, then I need to do it for all 50!).
**I don't think Loop & Merge is the right solution here. Maybe embedded data? Maybe JavaScript?**
Any solutions would be much appreciated. I do not know JS, unfortunately.
Thanks for any help you can attempt!

I think this would be fairly easy to do just put each scenario fully in a group and randomize the groups. Within those groups you would also have randomizers to determine a winner or not.


It's a pretty quick design. Loop and Merge will not allow you to change your randomizer for what the winners are. That's the snag. In the simplest form it's pretty easy to duplicate the logic. Preview Link: https://feedback.digikey.com/jfe/preview/SV_2rBqFlgTXfR7aLk?Q_CHL=preview&Q_SurveyVersionID=current
Ranomizer: Present 3 of the following elements:
Group: Scenario A
Initialize all Dice Rolls as 0
Randomizer: Present 1 of the following elements:
ARoll1 = 10 // One element (embedded data) to set 1 as the winner
ARoll2 = 10 // One element to set 2 as the winner
ARoll3 = 10 // One element to set 3 as the winner ...
ARoll4 = 10
ARoll5 = 10
ARoll6 = 10
Show Block: Scenario A // This is where you display $${e://Field/ARoll1} for each number
Group: Scenario B
Initialize all Dice Rolls as 0
Randomizer: Present 2 of the following elements:
BRoll1 = 10 // One element (embedded data) to set 1 as a winner
BRoll2 = 10 // One element to set 2 as a winner
BRoll3 = 10 // One element to set 3 as a winner ...
BRoll4 = 10
BRoll5 = 10
BRoll6 = 10
Show Block: Scenario B // This is where you display $${e://Field/BRoll1} for each number
...


Loop and Merge isn't scalable in that way, BUT you could use embedded data to pull in your question text and then you would just change it before once and used the piped text in all the scenarios.
Also if you didn't care what numbers selected for each scenario you could double up and just use one set of embedded data. You would be able to use one block to display the results, but you would just have to duplicate it in the Survey Flow. You would copy the whole block and just change your randomizer number.
Do you care about what order they see it in or what scenarios they were presented? Those you could store in embedded data, but complicate things a little.


MSobotta I checked out the preview link. Yes, yes, yes! This is great! Would you mind uploading the .qsf file so I can look at the finer details?


No problem. Let me know if you have questions.
QCommunity_Randomizer_Dice_Game.qsf


MSobotta for the win! This is fantastic. Thanks so much for a clever solution that perfectly accomplishes what I need! 🙂 Really appreciate it.


Leave a Reply