Description of the problem:
Hello, I’m trying to run an experiment online where participants have to respond to a stimulus within a given time frame. If they run out of time, there is a beep and the next trial begins.There is first a practice block where feedback is given. The experiment was created in Builder and the feedback code is in a code component. This is what it looks like:
if response.keys == None:
msg=“Too slow!”
else:
msg=“Success!”
It works perfectly offline but when run online, the experiment just hangs with no error message when no response is given (it runs fine and gives the right feedback when a response IS given).
There are various translations of the code I’ve tried such as:
if ((response.keys === null)) {
msg = “Too slow!”;
} else {
msg = “Success!”;
}
Thanks for the suggestion. Unfortunately, this has the effect that the “too slow” warning appears one trial too late offline and it still doesn’t work online.
Sorry for disappearing for a while.
I realised from your posts that the problem is not with the feedback but with not giving a response. In the online version, the experiment won’t move on to the next routine when no response is given. This is the code I’ve tried based on your suggestion (the reponse is a keyboard reponse when given).
A code component at the end of the trial routine (also tried to put it in the next routine within the loop, with the same result):
responsegiven = 0 (in both Begin Experiment and Begin Routine)
in Each Frame:
if response.keys:
responsemade = 1
continueRoutine = False
in End Routine:
if responsemade == 0:
continueRoutine = False
I’ve also tried to replace “if response.keys” with “if len(response.keys) > 0”, which gave me an error message that Cannot read property ‘length’ of undefined
You only run the code in End Routine when the routine is already ending. Presumably you want to end the routine after a given time period. Do you have any code doing that?
There is a 0.3 sec beep 9 seconds after the start of the trial and the routine should end after the beep. I’ve tried inserting the code (in Each Frame):
if t >= 9.3:
continueRoutine = False
I’ve also tried:
if beep.status == FINISHED:
continueRoutine = False
Looking at that image you shouldn’t need any code at all to timeout unless you also have code objects . However, I can’t see a feedback routine. I normally put one inside the loop after the trial
I don’t need any code for the experiment to run offline. It runs perfectly without the code component. But when I try to run it online, it just hangs after the beep and nothing will make the trial routine end.
(The feedback routine used to be inside the loop after the trial but I deleted it when I thought that was the source of the problem. I’ll put it back once the never ending routine problem is solved.)
Yes, that was it! I had the sound component generate a tone of 0.3 sec duration and the online version thought the sound component never ended. Now I’ve created a sound file of 0.3 sec duration, which is called by the sound component and it’s working fine.