How to combine a random draw, pipe a decision, play a lottery and save the outcome? | XM Community
Question

How to combine a random draw, pipe a decision, play a lottery and save the outcome?

  • 25 June 2020
  • 3 replies
  • 80 views

Hey everyone!
I will try it again, since I did not succeed so far and I think my previous discussion (https://www.qualtrics.com/community/discussion/10800/how-to-randomly-draw-one-of-the-rows-in-a-biploar-matrix-and-display-the-choice-of-the-respondent#latest) was misplaced.
So, I have a lottery with 10 different decision situations in which subject chose between A and B, see below
image.pngIn a separate question, I would like to
i) announce which of the 10 decision situations (basically rows in a bipolar matrix) has been randomly chosen (1-10)
ii) recall the choice they made in that particular decision situation (A or 😎 and
iii) play the lottery of that particular choice (depends on i) and ii): e.g. if decision situation 7 was drawn and the participant chose A, the lottery we are playing is 70% chance of lets say a blue ball and 30% chance of a red ball)
iv) announce the amount of money subjects won (eventually calculations needed, if e.g. only 50% of lottery prize is actually payed out)
v) IMPORTANT: save the amount of iv in embedded data
I would highly appreciate any help. This being said, I am a complete novice to JS and am barely able to write codes and would need a really simple step-by-step explanation.
Cheers


3 replies

Userlevel 2
Badge +3

I think this is actually achievable in survey flow with branching and random numbers. There are a few different ways (all somewhat tedious) to do this. I would probably favor:

  1. create a couple embedded data fields in the survey flow immediately after this matrix question. Set 'lottery' equal to either A or B, depending on the respondents selection. And set 'decisionSituation' to a random integer between 1 and 10.

  2. optionally, create another embedded data fields called 'explanation' and create 10 branches that describe in english each decision situation. So if decisionSituation is equal to 1, 'explanation' will be set to "In lottery A, you have a 10% of winning $20 and a 90% chance of winning $16. In lottery B, you have..." again, it's optional, see step 4 where it's relevant.

  3. within each of those 10 branches, define three more embedded data fields, I'll call them 'threshhold', 'winnings1' and 'winnings2'. 'threshhold' should be set equal to that first probability in each lottery. So in the branch where decisionSituation is equal to 1, threshhold should be 10. Where decisionSituation is 2, threshhold should be 20, etc... For 'winnings1' and 'winnings2' you'll actually have to create one more branch within each of your 10 branches. So under decisionSituation 1 branch, set winnings1 equal to 10 and winnings2 equal to 16, but then create another branch within that that says if 'lottery' is B, then 'winnings1' should be "$38" and 'winnings2' should be "$1" instead.

  4. next, display a static content question with lots of piped text that reads something along the lines of "Let's play a game. We've randomly chosen decision situation $e{Field/decisionSituation}. In this scenario, you had to choose between lotteries A and B. $e{Field/explanation} You chose lottery $e{Field/lottery}. Next, we will randomly draw a number between 1 and 100. If the number is between 1 and $e{Field/threshhold}, you will win $e{Field/winnings1}; if not, you will win $e{Field/winnings2}. Click next to select your number.

  5. and then you create another embedded data field 'randomNumber' that is a random integer between 1 and 100. also create a branch if 'randomNumber' is less than or equal to 'threshhold', set 'actualWinnings' equal to 'winnings1', else 'winnings2'.

  6. finally, display another static content question with piped text "Your number is $e{Field/randomNumber}, this means you have won $e{Field/actualWinnings}

I'm sure there are tweaks to that that you can make, but hopefully that's a starting point if that makes sense. I honestly don't know if there's a js way to do this that's any easier.

Great! This is indeed quite complex, but it seems to (almost) work!
I combined your suggestion with TomG suggestion in the other thread with some JS. I am very happy that I got to this point with your help! Thanks!
The "outcome" screen for participants now looks like this:
image.pngThe last thing that needs to be fixed is the winnings. I pipe the text as follows, but the winnings do not appear.
"We randomly drew decision situation number ${e://Field/randRow} from Lottery ${e://Field/Lot}, in which you selected lottery ${e://Field/randRecode} (Lottery A = 0; Lottery B = 1).
To determine your payoff, you will play the following lottery:
We now draw a random number between 1 and 100. If the number is equal to or below ${e://Field/thres}, you win ${e://Field/winnings1} otherwise you win ${e://Field/winnings2}. "
image.pngI tried two different ways to create the embedded date fields.
Option 1 (use embedded data variable randRecode)
image.pngOption 2: use embedded data from question
image.pngneither of the two works unfortunately, as you can see.
Any advice?

Userlevel 2
Badge +3

Is your randonmizer only selecting one element (ie Set Embedded Data OR Branch)? Does it work if you group the branches you want to the embedded data selections you want like this?
image.png

Leave a Reply