Hi Henrik,
You could use add a Footer
to every trial that checks how long it’s been since the experiment started and jump
s to a trial that sends the results if it’s been too long:
const start_time = Date.now()
Footer(
newFunction( ()=>Date.now()-start_time>(20 * 60 * 1000) ) // 20min
.test.is( true )
.success( jump("timeout") )
)
Sequence("intro", randomize("trials"), SendResults(), "end", "timeout")
newTrial("intro", newButton("Start the experiment").print().wait() )
newTrial("end", newText("This is the end").print(),newButton().wait() )
newTrial("timeout",
newText("You have timed out, we are sending your results to the server").print()
,
SendResults()
,
newText("Your results have been sent, thank you for your participation").print()
,
newButton().wait()
)
Jeremy