Reply To: Behavioural task score

PennController for IBEX Forums Support Behavioural task score Reply To: Behavioural task score

#5403
Jeremy
Keymaster

Hello Zoë,

Your script runs the test on your Key element as soon as it creates it (well, just after setting it to log) so it will always fail: there’s no time to press any key in the millisecond(s) between the creation of the Key element and the evaluation of the test. You want to run that test in the callback, whose content is evaluated after a keypress (you can pass a series of commands in a callback):

    newKey("question1", "FJ ")
        .log()
        .callback(
            getText(row.item).remove(),
            getText("instruction").remove(),
            getTimer("window").stop(),
            getKey("question1").test.pressed(row.correctKey)
                .success(getVar("score").set(v=>v+1))
        )

About the Var element, I reckon things are tricky there, and actually I should probably change that, but technically within a trial you cannot refer to a named element that hasn’t been declared in that same trial. In other words, any get* command must be preceded by a corresponding new* command. So here is what you should do for your score_time trial:

newTrial("score_time",
    newVar("score").global()
    ,
    newText("Your score on the recall task was: ")
        .after(newText("").text(getVar("score")))
        .print()
        .wait()
)

Jeremy