Forcing the end of experiment

Hi, I have created a perceptual experiment in builder, uploaded it to pavlovia and everything is working fine.
But now I would like to add a feature to my experiment:
In the beginning, in a routine where I ask the participants if they have Portuguese as mother language, I would like that if they click ‘yes’ (with mouse) they move on with the experiment, but if they click ‘no’ they move to a routine where it says they don’t fit the criteria and after the experiment ends. (but this routine wouldn’t show in the experiment for those who clicked yes).
Is this possible? Is there a psychopy model experiment where I can find how to do this?
Thank you,
Gabriela

Hi Gabriela,

In the routine where you ask participants if they have portuguese as a mother language add a code component and in the end routine type:


if myMouseName.clicked_name[0] == 'yes':
    portugeseLang = 1
    endMsg = 'thanks for taking part'
else:
    portugeseLang = 0
    endMsg = 'thanks but you cannot take part'

then wrap a loop around everything that should be skipped for those who do not have portugese as a mother language and in the nReps parameter use portugeseLang. You could then use the variable endMsg to deliver a custom message in the last routine.

Here is a demo to help skipToEnd.psyexp (15.9 KB)

Good luck with it!
Becca

Hi, @Becca, thank you for your help :slight_smile: I’ll check it and if I have a problem, I’ll write you again.
Gabriela