Controller or Timer conditional

PennController for IBEX Forums Support Controller or Timer conditional

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8120
    emauffray
    Participant

    Hi Jeremy,

    Thank you for the support! I have another question. I am trying to have trials that move to the next one when the participant either responds to the Controller (Acceptability Judgment) or the timer runs out. I have been searching forums but was unable to find documentation about stopping the timer if the Controller has a response. Here’s a sample trial where I tried to use callback function:

    newTrial("trial-1", 
        defaultText
            .center()
            .print()
        ,
        newAudio("llego-profesora", "La_profesora_llegó_a_la_clase_en_la.mp3")
            .play()
        ,
        newText("llego-profesora-t", "La profesora llegó a la clase en la momento preciso.")
            .center()
            .unfold(3650)
        ,
        getAudio("llego-profesora")
            .wait("first")
        ,
        newTimer("hurry", 3000)
        ,
        newController("AcceptabilityJudgment",
        {q: "¿Es esta oración aceptable?",
        s: "",
        as : ["SÍ", "NO"], 
        instructions : "Haz clic, SÍ o NO",
        presentAsScale : true,
        leftComment : "es aceptable",
        rightComment : "no es aceptable"})
            .center()
            .print()
            .log()
            .callback(getTimer("hurry").stop())
        ,
            getTimer("hurry")
            .wait()
    )
    ;

    Here’s a link to my experiment.

    Any advice is greatly appreciated! Thank you for your continued support!

    Sincerely,
    Erin

    #8121
    Jeremy
    Keymaster

    Hi Erin,

    There are two issues with the code above: 1) the Timer element is not started, so it will be waited for forever, and 2) there seems to be a bug in the callback command of the Controller element!

    So you’ll need to work around the Controller element’s callback command. Here’s a suggestion, which consists in placing a wait command inside another callback command (this time, a bug-free one, called on a Timer element) so that wait does not block the main thread of execution:

    newTrial("trial-1", 
        defaultText
            .center()
            .print()
        ,
        newAudio("llego-profesora", "La_profesora_llegó_a_la_clase_en_la.mp3")
            .play()
        ,
        newText("llego-profesora-t", "La profesora llegó a la clase en la momento preciso.")
            .center()
            .unfold(3650)
        ,
        getAudio("llego-profesora")
            .wait("first")
        ,
        newTimer("hurry", 3000).start()
        ,
        newTimer("dummy", 1)
            .callback(
                newController("AcceptabilityJudgment", {
                    q: "¿Es esta oración aceptable?",
                    s: "",
                    as : ["SÍ", "NO"], 
                    instructions : "Haz clic, SÍ o NO",
                    presentAsScale : true,
                    leftComment : "es aceptable",
                    rightComment : "no es aceptable"
                })
                    .center()
                    .print()
                    .log()
                    .wait()
                ,
                getTimer("hurry").stop()
            )
            .start()
        ,
        getTimer("hurry").wait()
    )

    Jeremy

    #8124
    emauffray
    Participant

    This worked perfectly! Thank you so much!

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