Hello there.
I have put an attention check in my experiment to see if participants respond accurately to the questions. I ask a question and participant should press either ‘y’ or ‘n’ on keyboard to repond.
What I want to do is to end the routine and go to the next trial if pressed yes and end the experiment and show a message for a specific duration for participant so they can read the displayed text thouroughly.
As I will run the experiment online I would really appreciate the JS code for this.
What I have right now is this:
In Python:
if key_resp_15.keys == 'n':
msg = 'Thank you. Please write down this code and go to Prolific website to claim your gift.'
core.quit()
In JS:
if ((key_resp_15.keys == "n")) {
psychoJS.quit({message: 'Thank you. Please write down this code and go to Prolific website to claim your gift'});
}
But I am quite sure this code is not complete and needs modification.
I would also be very grateful if you could tell me in which really
Any help is really appreciate as my deadline to sumbit my work is very close!
I guess if you are asking how you can give feedback to your ‘y’ answer and move on to the trial. Then I would probably write a simple
if ((key_resp_15.keys == "n")) {
psychoJS.quit({message: 'Thank you. Please write down this code and go to Prolific website to claim your gift'});
} else if ((key_resp_15.keys == "y")) {
continueRoutine = false;
}
Then create another routine afterwards that will display a textstim for the desired amount of time. after that comes your trial.
Thank you very much for your quick response. What I mean by the duration of the message to be displayed is about the message which is displayed in the
psychoJS.quit({message: 'Thank you. Please write down this code and go to Prolific website to claim your gift'});
How can I specify the duration this message remains on the screen? It needs to be on screen at least for 10 seconds so that participants can read it before the experiment is terminated.
Besides, previously people who used this psychoJS.quit({message: … reported that they get this error that message is not defined.
So you mean is it possible to define a conditional routine that if participants responded no, they go to that routine and if yes to the rest if routines?
It seems a kind of branching. Can you tell me how I can potentially do it in code component?
You’re helping a lot
Apologies Hamed, I meant for the “yes” answer rather than the “no” answer. I’m not sure what the best solution would be in this case.