End Experiment if Participant clicks No on slider

If this template helps then use it. If not then just delete and start from scratch.

PsychoPy version (e.g. 1.84.x): 2022.2.5
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: remove participant if they say no


I am making a consent form for my experiment and I am using the consent_form template provided in PsychoPy, especially as the submit button appears only once participants have answered every consent question, and I am not knowledgeable on coding.

However, the issue is that clicking “No” on any of the questions still makes the submit button appear and allow non-consenting participants to continue in the experiment, which I do not want. (see pic).

Is there a way to end experiment when a “No” response is clicked and submitted on any of the slider consent questions? As my experiment will be uploaded to Pavlovia, it will need to be able to run online too if the solution requires code.

Nevermind, I have solved it. It will not end the routine but as a workaround, I have found a way for the submit button to not appear if any of the "No"s have been clicked, so participants who do not consent cannot continue in the study.

#In the Begin Routine tab in the code component
submit_button.size = (0, 0)

#In the Each Frame tab
if resp1.rating == 1 and resp2.rating == 1 and resp3.rating == 1 and resp4.rating == 1 and resp5.rating == 1 and resp6.rating == 1 :
    submit_button.size = (0.2, 0.1)
elif resp1.rating == 2 or resp2.rating == 2 or resp3.rating == 2 or resp4.rating == 2 or resp5.rating == 2 or resp6.rating == 2 :
    submit_button.size = (0, 0)

#Notes: The resp1, resp2 etc are the slider names and the numbers represent tick answers (1 = Yes, 2 = No).

Hopefully that’s input correctly. But yeah, the submit button no longer appears if even a single “No” is selected. I know the solution turned out to be rather simple, but I hope this is helpful for anyone else in my conundrum, especially if youre a non-coder like myself.

1 Like