Hi there,
I have a routine with two rating scales (gender and age).
The end of the routine will be forced by pressing the right arrow key.
OS Win10 PsychoPy version 3.0.5 Standard Standalone? y
What are you trying to achieve?:
I want to achieve that it is not possible to force the end of the routine before the ratings have been made. Here is my current setup:
What did you try to make it work?:
Am I right that I have to insert a code component that checks if the variables ‘gender’ and ‘age’ have assigned values? If so, how is it possible to do that?
Hi @Fabian, I would advise that you use the new Slider scale . The Slider has an option to end routine on rating, so you can just deselect that option and the routine will continue after each rating. Slider also available to use in your online studies.
Hi @dvbridges,
the same option exist for the ‘old’ rating component. I have already deselected this. Actually, I want to avoid that the participants can skip this page by just using the right arrow key to go to the next routine without a rating. So, I want to force them to do the rating. Just deselecting the option to end routine after each rating would not prevent that.
I’ve been looking to do the same as above and make it compulsory that a participant selects their gender before being able to continue with the experiment.
Based on the above I’ve used the following code:
if SelectGender.getRating() is not None:
if Continue2Age.keys == ‘space’:
continueRoutine = False
SelectGender is the name of my slider and Continue2Age is the name of my response key but this doesn’t seem to be working and I can still continue the routine without selecting anything.
I did try this but when I removed the force end of routine option in the keyboard, the routine won’t regardless of whether or not a response has been made.
If you go to your keyboard, and make sure that ‘space’ is an allowed key, and that Store is set to last key, and the duration of the keyboard is infinite (blank). Then in your code components “Each Frame” tab:
if SelectGender.getRating() is not None:
if Continue2Age.keys == ‘space’:
continueRoutine = False
# Clearing these makes sure no previous keypress can end the trial after a rating is made
Continue2Age.keys = []
Continue2Age.rt = []
here is my solution if you are interested (Each frame):
keys = event.getKeys()
if 'space' in keys:
completed_ratings = 0
for slider in [r1, r2, r3, r4, r5, r6, r7, r8, r9, r10]:
if slider.getRating() is not None:
completed_ratings = completed_ratings + 1
if completed_ratings == 10:
continueRoutine = False
I have ten ratings (r1, r2, …, r10) in this routine. The if-function checks if each rating has a “completed_rating”. Only if “completed_ratings == 10” the participant is able to end the routine by pressing the space bar.
This worked for me too!! I just used the name of my 4 sliders and added a keyboard item (without force clicked) and then this in the everyframe of a code portion, as you outlined. Thank you for sharing!
I’ve found an error with this method-- The screen won’t move on unless all 4 ratings have a marker on them, but even without clicking the bar (just hovering over and showing the marker) the slider.getKeys function views the rating as “pressed” (even though the csv data then says “None” still in the field. Does anyone know why this happens or how to prevent it?
You can see in the data output that it’s being coded as “None”. Here is a video of how it looks when it allows me to skip vs. when it doesn’t. I have the sliders coded to disappear when an answer is pushed:
{{ it won’t let me upload a video, is there a suggestion how I can share that? }}
Ah, I see. I would recommend switching to the Slider component, its a modern version of rating scale that is simpler to use and configure. My code above assumed you were using Sliders.
Hi @dvbridges,
thank you for this response. I believe I am using the Slider component-- that’s what is says in Builder. What makes you think that I’m not? When I look up slider here that is what I am using.
You’re right, I found out what you were referring to. However, the slider doesn’t allow me to set to “single click”, change the marker type, or set “disappear=True”. I tried adding directly into the builder code and it says invalid syntax.
I’ve tired some custom code to make the element disappear but it doesn’t work either.
In a new “Each Frame” coder component:
for slider in [slider_1]:
if slider.getRating() is not None:
completed_slider=1
if completed_slider=1:
visual.Slider[slider](disappear=True)
This code doesn’t break the script, but it also doesn’t do anything.
Hi, please can you/someone help me, what to put instead of 'if Personnel_FeoR.keys == ‘right’: ’ when my response is done by mouse and not by keyboard (people have to give rating on a scale and then click on the text below that they want to continue). Thank you!!!