Consent Form In PsychoPy Builder

Hello, I am a grad student and I’m stuck on part of my experiment.

I am trying to create an experiment in the PsychoPy Builder that will run properly when I upload it to Pavlovia.

Everything works fine except for the consent screen. (I tried making it a consent form, using the form component, but any time I have pulled in a document from my desktop, it has not worked when I tried to run it on Pavlovia).

The consent screen is just some text (the consent info) and then two “buttons” (made using two shape components and text on top of it; they say “i do consent” and “i do not consent”).

If they do consent, I want the experiment to go forward.

If they do not consent, I want the experiment to go to the debriefing screen. (This is a requirement set by my university).

I have tried adding a code component:


if mouse.clicked_name[i_do_consent] == correctAnswer:
thisExp.addData(‘correct’, ‘1’)
thisExp.addData(‘correct’, ‘0’)

Variations on this code have included

  • For mouse.clicked_name: mouse.PressedIn, mouse.getPressed
  • For correctAnswer: correct, corrAns
  • For thisExp.addData: psychoJS.experiment.addData

I have read that apparently mouse.PressedIn doesn’t work on Pavlovia, and I’m trying to not have to have the experiment go to online consent or debriefing forms.

If you have any advice/ideas, please let me know.


Unfortunately, forms (and rating scales) do not work on Pavlovia so you could use sliders or an embedded html form. I have an example of the latter in my template Pavlovia

1 Like

Hi @Cristina_Weiner , the isPressedIn mouse method has now been implemented for PsychoJS in the latest versions of PsychoPy, so you could also build some accept / decline buttons using text and polygons.

Hi dvbridges.

Sorry, I’m quite new to programming so I may be one of the more inexperienced people on here. Currently, my consent screen looks something like this:

(The accept and decline buttons were made with text and polygons in the builder)

If they press “I do consent,” then I want them to move on to “demo”, which is the demographics form. From there, they would go on to the experiment.
If they press “I do not consent,” then I want them to move on to “debrief”, which is the debriefing form. I’d then have an instruction in there telling them to press ‘esc’.

In order to accomplish this, I tried:

if mouse.isPressedIn[i_do_consent] == correctAnswer:
thisExp.addData(‘correct’, ‘1’)
thisExp.addData(‘correct’, ‘0’)

Unfortunately, this results in this error:

if mouse.isPressedIn[i_do_consent] == correctAnswer:
TypeError: ‘method’ object is not subscriptable

Can you please advise me on what I should do next?

You just need to use round brackets to call the function, rather than square brackets.

To get them to skip the debrief loop, then store your "consent " variable, and you can use it in the debrief loop to determine whether or not to present the loop. E.g., in consent

if mouse.isPressedIn(i_do_consent):
    consent = 1
    continueRoutine = False
elif mouse.isPressedIn(i_do_not_consent):
    consent = 0
    continueRoutine = False

# End Routine
thisExp.addData("consent ", consent )    

Then in your debrief routine, add a code component and in the “Begin Routine” tab:

if consent:
    debrief_loop.finished = True
    continueRoutine = False

How do I store the consent variable?

This line as provided by David does that:

thisExp.addData('consent', consent )

I had the routine named “consent” as well, so that’s why it wasn’t working. Thanks!

Well, it worked in the PsychoPy builder, but when I went to upload it to Pavlovia, I got the error ReferenceError: consent is not defined.

Is there something else I might need to change? (I’ve heard sometimes certain things don’t translate into Pavlovia so I wasn’t sure if there was something different or additional that I could do).

Normally if you have x is not defined then you need to put x=0 (or “” or []) in a Begin Experiment code tab.

Hopefully you no longer have a routine called consent.

I changed the routine called “consent” to “consent_screen.” I tried adding x=0 into the Begin Experiment code tab, and still got the same error.

I changed x=0 to consent=0 and then got this error: ReferenceError: thisExp is not defined

So the I changed thisExp to the title of my experiment and got this error: * TypeError: mouse.isPressedIn is not a function

Is there maybe a particular setting I should check, or possibly somewhere else in my experiment that might be causing these issues? (I’m not sure if it is allowed, but I’d be happy to upload my experiment or send the Pavlovia link if it might help).

You need to define thisExp in code_JS as per my crib sheet (see pinned post in the online category)

Thank you. At my meeting with my lab advisor yesterday, he told me that he’d been looking into the ethics committee guidelines and said that if a participant decides that they do not consent to the experiment, then a debriefing form isn’t necessary as they wouldn’t even have begun the experiment on which to be debriefed. He said that my listed contact information would suffice for participants to use if they had questions, and I could just instruct them to press “Esc” to exit. Thanks for all your help.