PennController for IBEX › Forums › Support › timeout and skip to next task › Reply To: timeout and skip to next task
Let me know whether I understood your design correctly: you have a first block of trials labeled task_A and a second block of trials labeled task_B. In case your participant takes more than 4 minutes completing the first block (task_A) you want to prematurely end whichever trial the participant is currently on and skip all the remaining task_A trials, and jump directly to the first task_B trial.
What you can do to that end is set a global Var element before starting block task_A to a timecode corresponding to four minutes later. Then at the beginning of each trial of block task_A, you look up the current timecode and skip the trial if it’s over the timecode from the global Var element. Otherwise, you launch a Timer element that will check again later and either end the trial prematurely or re-launch itself.
Here is an example:
newTrial("pre_task_A", newVar("four_minutes_later").global().set(v=>Date.now()+4*60*1000) ) Template( row => newTrial( "task_A" , getVar("four_minutes_later").test.is(v=>Date.now()>=v).success(end()).failure( newTimer("check_end", 100).callback( getVar("four_minutes_later").test.is(v=>Date.now()>=v) .success( end() ) .failure( getTimer("check_end").start() ) ).start() , newText("Task A").print(), newButton(row.stim).print().wait() ) ) ) Template( row => newTrial( "task_B" , newText("Task B").print(), newButton(row.stim).print().wait() ) )
Let me know if you have any questions