PennController for IBEX › Forums › Support › timeout and skip to next task
- This topic has 2 replies, 2 voices, and was last updated 3 years, 11 months ago by ginopino09.
-
AuthorPosts
-
December 7, 2020 at 12:14 pm #6433ginopino09Participant
Hello Jeremy,
I’m planning my next experiment and I am having some problems with the newTimer function. I already used this function to provide feedbacks but what I need this time is slightly different.
Participants will be doing task_A for 4 minutes and when the time is over (regardless how many trials they completed) they will go the next task_B.I have two problems with what I have writted so far: 1) I get the message only when a key is pressed (so if the 4 minutes ends in the middle of a trial, the message pops out only once that trial is over). 2) I do not know how to end the present task_A and go to the next after the 4 minutes.
Any suggestion? Thank you in advance!Template("kbit", row => newTrial( newTimer("kt", 240000).start(), newImage(row.slide).print(), newKey("ABCDEFGH").wait() .settings.log(), getTimer("kt").test.ended() .success(clear(), getTimer("kt").stop(), newText("I'm sorry, the time is over").css({'font-size':'1.5vw'}).print("center at 50%", "middle at 30%"), newButton("go","Go to the next task").css({'font-size':'1.5vw'}).print("center at 50%", "middle at 50%").wait()), // ...?
December 7, 2020 at 1:45 pm #6434JeremyKeymasterHi,
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
Jeremy
December 9, 2020 at 5:57 am #6438ginopino09ParticipantThank you Jeremy! It worked!
-
AuthorPosts
- You must be logged in to reply to this topic.