Ending the experiment when participants do not agree to participate

I’ve not heard of continueExperiment

I’m on my phone but if you check my crib sheet you’ll fine core.quit() and the JS translation

Thanks @wakecarter,

I put core.quit() in my code and it works. I want to ask another question: How can I show a message before quit the experiment when ‘I do not consent’ will be clicked?

Cheers,
Mohammad

I’m stilling experimenting with how to customise the quit message. I got it working locally but it went back to “The user pressed Escape” online.

You could have a routine with a duration of 0 if consent has been given and 2 or 3 seconds when consent isn’t given and put the core quit in that routine (end Routine if duration > 0

Hi @wakecarter,

I uploaed my experiment to Pavlovia but the code does not work and I got the error: core.quit is not a function!
What kind of code do I need for online experiment to end the experiment for a conditional response?
I will appreciate any help.

The correct translation of core quit is on my crib sheet

I tried both of these code:
psychoJS.quit({message: 'Your custom message’});

OR

quitPsychoJS(‘Your custom message’, false);

But non of them work for me nor online neither offline.

If you try to run https://run.pavlovia.org/Wake/ebbinghaus-darts/html

you’ll see the effects of this JS code

mouseloc = mouse.getPos();
if (((mouseloc[0] === mouserec[0]) && (mouseloc[1] === mouserec[1]))) {
} else {
    if ((rec.contains(mouse) && (expInfo["researcher"] === "12345678"))) {
        mouserec = mouseloc;
        continueRoutine = false;
    } else {
        if (rec.contains(mouse)) {
            psychoJS.quit({message: 'Please click to go to the participant information sheet'});
        }
    }
}

Hi @wakecarter,

I got an error with the link above. I don’t know where can I add my clickable response to this code and adjust it with my experiment.
I will appreciate any help.

What happens when you click on the Ebbinghaus Darts link?

It gives me this error:

@jon Any thoughts about this error? I feel like I sometimes see a red bar box briefly which then goes before I can read it.

Hi,

I tried to find another way to solve the problem. I wrote this code:
if mouse.clicked_name[0]==“polygonconsent”:
continueRoutine =False;
else:
msg = “Thank you. To exit the experiment press Esc in your keyboard.”
msgcolor=‘green’
Now, it works perfectly offline. I will upload it as soon as possible to see whether it works online.

A completely different way to approach this would be to do as you did before, i.e. with a bit of code at the end of the first routine:

if mouse.isPressedIn(text_notconsent):
    consented = 0
if mouse.isPressedIn(text_consent):
    consented = 1

Then, make a loop around your entire experiment with the number of repetitions set to the variable $consented. Finally, make an ending routine outside of the loop at the very end with a text object that says “Thank you” and a keyboard object that lets them press enter to end the experiment.
This way, if they click “I do not consent” they do the experiment zero times and arrive at the end.

1 Like

I have the same code working in one experiment and failing in another.

In Ebbinhaus Darts https://pavlovia.org/Wake/ebbinghaus-darts I have:

Each Frame

mouseloc = mouse.getPos();
if (((mouseloc[0] === mouserec[0]) && (mouseloc[1] === mouserec[1]))) {
} else {
    if ((rec.contains(mouse) && (expInfo["researcher"] === "xxx"))) {
        mouserec = mouseloc;
        continueRoutine = false;
    } else {
        if (rec.contains(mouse)) {
            psychoJS.quit({message: 'Please click to go to the participant information sheet'});
        }
    }
}

It seems to alternate between Please click to go to the participant information sheet and The [ESC] key was pressed.

In Prospective Memory LDT https://pavlovia.org/Wake/prospective-memory-ldt I have:

End Routine

if ((expInfo["researcher"] !== "xxx")) {
    psychoJS.quit({message: 'Please click to go to the participant information sheet'});
}

and I end on an error ReferenceError: message is not defined

1 Like

Unfortunately it doesn’t work online.

Dear Hamzeloo,
Did you get any solution to solve this issue?
I am also seeking the same.
Please let me know.
Thanks,
Sumathi.

Dear @Sumathi

Sorry for the delayed response. I used two polygons for the page related to the consent form and I made them clickable. Then I used this code in the tab “Each Frame”:
if mouse.clicked_name[0]==“polygonconsent”:
continueRoutine =False;
else:
msg = “Thank you. To exit the experiment press Esc on your keyboard.”
msgcolor=‘green’;
Explanation: “polygonconsent” is the name of clickable polygon for consent to participation.

I hope this works for you too.
Best regards,
Mohammad

Thank you so much!
I will try this one and will let you know.
Cheers!
Sumathi.

Hello,
Does this code work online? Or just local experiments?

Best,
Paige

Hello,

I use a different approach. I have a GDPR-routine in which the participants are asked to press one of two keys. If they do not wish to participate, I set a counter for a loop following the GDPR-routine to 1, otherwise the loop-counter is set to 0. In case, the counter is set to 1, the loop is executed showing some text (2 sec.) that the experiment now ends because of missing consent and I end the experiment with a

core.quit()

in the end routine tab.

I used this approach because I only used key-presses in the experiment and did not want the participant to switch between keybaord and mouse.

Best wishes Jens

1 Like