Sequence timing
Hi!
In my current experiment I want people to be able to fill something in for 12 seconds. If they haven't filled anything in by that time, they should automatically go to the next trial.
Participants will type in a score and are able to switch between the boxes with the left and right arrow keys (the green box around the textbox indicating which one they've selected). Once they are done and rated all 3 items they can press enter and continue to the next trial themselves if they don't want to wait out the 12 seconds.
The issue here is that I've set the keyboard response timer to 12 seconds, which works if they never touch anything. However every time they click a button the loop is repeated. This means that 1 trial can basically go on forever if people just keep switching between textboxes for example.
Therefore I was wondering if there is a way to time how long a sequence (click sequence in this case) has been running, if the sequence has been running for 12 seconds, then the loop should end.
I hope you can help!
Kind regards,
Sanne
Comments
Hi @Sannee ,
Sorry for not getting back to this question earlier. And yes, you did the right thing opening different threads for different questions! :)
Could you check whether the following logic works?
inline_javascriptitems. One before starting theloopthat collects the clicks, the other one at the beginning of the clicksequence, like so:Runtab of the firstinline_javascriptitem:Runtab):// Get current timestamp vars.current_time = new Date().getTime(); // Calculate the time that is passed: vars.time_passed = vars.current_time - vars.starting_time // Update the timeout: vars.var_timeout = 12000 - vars.time_passed // Make sure that the timeout cannot be negative: if (vars.var_timeout <= 0){ // Change the variable keeping track of whether // a timeout occurred vars.timeout_occurred = "yes" } console.log("time passed = " + vars.time_passed)Run-ifstatements to only run the remainder of the clicksequenceif no timeout occurred:Repeat-ifstatement in therepeat_cycleelement, making sure that we break from the loop if a timeout occurred:[check] == no and [timeout_occurred] != "yes"I attached the modified script. I hope this results in the behaviour that you are looking for.
Cheers,
Lotje
Did you like my answer? Feel free to

Hi Lotje!
No worries at all!
And this indeed works exactly as I wanted it too! Such a simple solution but in all honesty I would never have found it myself. Thanks so much for your help not just on this question but all the others as well!
Kind regards,
Sanne