psychopy.org | Reference | Downloads | Github

Terminate a loop when a rating is selected

Hi,
I’m in builder mode and I’m trying to create a screen with a rating scale such that the participant can only advance to the next screen if they select a “4”.

My attempted solution was to create a routine with a rating scale inside it. Around this routine, I created a loop with a very large number of repetitions (10,000). The rating scale is set to “force end of routine”, such that when the participant selects any value, the loop advances (10,000 to 9,999 to 9,998 etc.) to the next routine, but the loop should only terminate if they select a 4.
Inside the routine I created a code component and inserted these lines:

if RatingScaleName == 4:
LoopName.finished = True
if LoopName.finished:
continueRoutine = False

I’ve tried placing these lines inside the “End Routine”, “Each Frame”, etc. but none of it worked.
Regardless of what I select on the rating scale, it just continues the loop, going on to the next routine out of 10,000, rather than ending the loop when I select a 4, which is what I want.

Help? Thanks!

(I’ve found several other posts with a similar problem, but none of the given solutions worked for me. And yes I’ve looked in the manual.)

There’s a pretty good rating scale demo in the builder demos.

Sounds like the function you want is rating.getRating()
Something along the lines of (not tested/pseudocode):

if rating.getRating() == 4:
    trials.finished = True
    continueRoutine = False

Oli thanks again! That worked great.