Random rating scale order

Hey there,

The main part of my experiment consists of a randomly selected photo and then a set of 3 rating scales (one after another). I would like the scales to appear at a random order every time after a photo. At this very moment I am out of ideas as to why my setup doesn’t work, because I checked the code below both on Python 3.6 and Python 2.7 and it seems to be working as intended.

Let’s name the scales q1, q2 and q3. Every one of them is inside a separate routine. Below how my timeline is set up at the moment:

  1. a photo

  2. routine with a code component:
    rand = {0: {'q1': 1, 'q2': 0, 'q3':0}, 1: {'q1': 0, 'q2': 1, 'q3':0}, 2: {'q1': 0, 'q2': 0,'q3':1}}
    order = random.sample(list(rand),3) turn = 0

  3. 4 routines wrapped with a loop (nReps = 3)
    3A.1. code component:
    if rand[order[turn]]['q1'] != 1: continueRoutine = False
    3A.2. q1 - rating scale
    3B and 3C look the same as 3A (the code of course adjusted accordingly)
    3D. code component (tried both inside begin routine and end routine):
    turn =+1

The whole thing repeats a number of times, let’s say 10.

From my understanding the effect of my setup would be 3 rating scales appearing in a random order changing every time after a photo is shown. Instead of that, it very often happens that one question appears two or even three (out of three) times, so for example: q3-q3-q1, q2-q1-q1 and so on.

Maybe it’s something obvious, maybe it’s not. Anyway I would be very grateful for any ideas!

Best Regards,

Mat Gaca

On your ‘photo’ routine, insert a code component and in its Begin experiment tab put:

rating_order = [0, 1, 2]

In that same component, in the End routine tab, put:

shuffle(rating_order)

Following that routine, place your three rating routines consecutively.
Surround just those three routines in a loop with nReps = 3 (i.e. nested within your outer loop, and not connected to your conditions file). Call this loop, say ratings.
On each rating routine, insert a code component and in its Begin routine tab, put this:

if rating_order[ratings.thisN] != 0:
    continueRoutine = False

In the second and third rating routines, test against 1 and 2 instead of 0.

i.e. you are looking up the entry in rating order list, indexed by the current iteration number. So on each iteration of the loop, only one of the three rating routines will execute.

e.g. rating_order is [2, 0, 1]. On the zeroth iteration, rating_order[ratings.thisN] is 2. So neither the first (rating 0) or second (rating 1) will play, but the last (rating 2) will. On the next iteration, rating 0 will run, and so on.

NB You don’t need separate routines to hold code components. It is usually better to insert them within standard routines.

Thank you very much, this works exactly the way I wanted to. I still am going to think about it because I’m not sure why my code didn’t do the same thing.

Regards

I’m sure your code would work with a tweak or too: I was just too lazy to try to figure it out and just suggested something I was more familiar with. The beauty of code is that there can be many right approaches to answer a problem.

Good luck with the experiment.