Reply To: Keeping track of participant accuracy

PennController for IBEX Forums Support Keeping track of participant accuracy Reply To: Keeping track of participant accuracy

#5906
Jeremy
Keymaster

Hello Miriam,

Both options should normally work. Here is an example script, switch the commenting // to test out the two options:

PennController.ResetPrefix(null)

AddTable("myTable", "Correct\nYes\nNo\nYes\nNo" )

Header( 
    // newVar("Acc", []).global() 
)

newTrial( "intro" ,
    newVar("Acc", []).global(),
    newButton("Start").print().wait()
)

Template( "myTable" , row => newTrial( "exp" ,
    newVar("computedAcc").set(getVar("Acc")).set(v=>v.filter(a=>a===true).length/v.length),
    newText("accuracy").text(getVar("computedAcc")).print("left at 5px", "top at 5px")
    ,
    newScale("answer", "Yes","No").button().print().wait()
        .test.selected(row.Correct)
        .success( getVar("Acc").set(v=>[...v,true]) )
        .failure( getVar("Acc").set(v=>[...v,false]) )
))

newTrial( "end" ,
    newVar("computedAcc").set(getVar("Acc")).set(v=>v.filter(a=>a===true).length/v.length),
    newText("accuracy").text(getVar("computedAcc"))
    ,
    newText("Final accuracy: ").after(getText("accuracy")).print()
    ,
    newButton().wait()
)

In this example I set the global Var element to an array of true‘s and false‘s so I can then compute the current accuracy on each trial by dividing the number of true‘s by the length of the array.

Note that some Var-related bugs were fixed with PennController 1.8, so make sure to update your version of PennController if the script above does not work for you

Jeremy