Timeout in Filled Inputs with failure test

PennController for IBEX Forums Support Timeout in Filled Inputs with failure test

Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10723
    utkuturk
    Participant

    Hi!

    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 7 months, 3 weeks ago by utkuturk. Reason: codeblock
    #10729
    utkuturk
    Participant

    I 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)
    );
    
    #10734
    Jeremy
    Keymaster

    Hi,

    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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.