PennController for IBEX › Forums › Support › Timeout in Filled Inputs with failure test
- This topic has 2 replies, 2 voices, and was last updated 1 year, 8 months ago by
Jeremy.
-
AuthorPosts
-
July 4, 2023 at 7:06 am #10723
utkuturk
ParticipantHi!
I am trying to implement a sentence completion task where the participant see a preamble and write the rest of the sentence. I am able to get timeout and failure test working separately. But, I cannot get them working together.
Here’s the link to the demo: https://farm.pcibex.net/r/Zzersk/
Here’s my trial with what I have tried:
// Practice Trials Template("PracticePreambles.csv", (row) => newTrial( "practice", newTimer(300).start().wait(), // white screen before the trial newTimer("timeout", 10000).start(), newText("Preamble", row.preamble) .center() .cssContainer({ "margin-right": "1em" }) .print(), newTextInput("answer") .settings.before(getText("Preamble")) .log("validate") .lines(1) .cssContainer("display", "flex") .print() .callback( getTimer("timeout").stop() ////// WITHIN THE CALLBACK: doesn't do anything, but timeout works // , // getTextInput("answer") // .test.text(/^(.{10,500})$/) // .failure( // newText("<b>Please write more.</b>").settings.color("red").print() // ) ), /////// AFTER THE CALLBACK WITH WAIT: neither timer nor the validation works, cannot even go to the next item // .wait( // getTextInput("answer") // .test.text(/^(.{10,500})$/) // .failure( // newText("<b>Please write more.</b>").settings.color("red").print() // ) // ) // , /// AFTER THE CALLBACK WITHOUT WAIT: timer works, failure doesnt work but we constantly see the failure message // getTextInput("answer") // .test.text(/^(.{10,500})$/) // .failure( // newText("<b>Please write more.</b>").settings.color("red").print() // ) // , getTimer("timeout").wait() ////// AFTER getTimer: timer works, but failure does not work // , // getTextInput("answer") // .test.text(/^(.{10,500})$/) // .failure( // newText("<b>Please write more.</b>").settings.color("red").print() // ) ) .log("Preamble", row.preamble) .log("Condition", row.condition) .log("ItemNumber", row.itemnum) );
-
This topic was modified 1 year, 8 months ago by
utkuturk. Reason: codeblock
July 4, 2023 at 4:01 pm #10729utkuturk
ParticipantI have solved the problem by using a dummy timer from this thread: https://www.pcibex.net/forums/topic/controller-or-timer-conditional/
I would be happy to know if there can be any improvement in this code.
Here’s the solution:
// Practice Trials Template("PracticePreambles.csv", (row) => newTrial( "practice", newTimer(300).start().wait(), //white screen before the trial newText("Preamble", row.preamble) .center() .cssContainer({ "margin-right": "1em" }) .print(), newTimer("hurry", 3000).start(), newTimer("dummy", 1) .callback( newTextInput("answer") .settings.before(getText("Preamble")) .log("validate") .lines(1) .cssContainer("display", "flex") .print() .wait( getTextInput("answer") .test.text(/^(.{10,500})$/) .failure( newText("<b>Please write more.</b>") .settings.color("red") .print() ) ), getTimer("hurry").stop() ) .start(), getTimer("hurry").wait() // add timelimit ) .log("Preamble", row.preamble) // add these three columns to the results lines of these Template-based trials .log("Condition", row.condition) .log("ItemNumber", row.itemnum) );
July 10, 2023 at 11:38 am #10734Jeremy
KeymasterHi,
Nice solution. A slightly simpler alternative would be to stop the hurry timer in the TextInput element’s callback instead of using a dummy Timer element to accomplish the same:
newTimer("hurry", 3000).start() , newTextInput("answer") .before(getText("Preamble")) .log("validate") .lines(1) .cssContainer("display", "flex") .print() .callback( getTextInput("answer").test.text(/^(.{10,500})$/) .success( getTimer("hurry").stop() ) .failure( newText("<b>Please write more.</b>").color("red").print() ) ) , getTimer("hurry").wait()
Jeremy
-
This topic was modified 1 year, 8 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.