PennController.SetCounter

PennController.SetCounter() (since PennController 1.1)

or PennController.SetCounter( "label" ) (since PennController 1.1)

or PennController.SetCounter( number ) (since PennController 1.1)

or PennController.SetCounter( "label" , number ) (since PennController 1.1)

or PennController.SetCounter( "inc" , number ) (since PennController 1.1)

or PennController.SetCounter( "label" , "inc", number ) (since PennController 1.1)

Creates an item that will set Ibex’s internal counter when it is run.

Ibex has an internal counter which keeps track of how many people participated in your experiment in order to automatically handle group designs. By default, the counter is incremented at the end of the experiment, which has the undesirable effect of assigning the same group to all the participants who click your link before anyone has completed your experiment. You can choose to run [js]SetCounter(“inc”, 1)[/js] at the very beginning of your experiment instead.

You can pass a label as the first argument, which you can then use in ”[jsSequence[/js]”]: this way you can make it the first item to run and therefore increment the counter at each click—provided you passed "inc" too. Note that, in the absence of "inc", if you pass a number then the counter will be set to that value.

The intended behavior of this command was to use the number to increment (if positive) or decrement (if negative) the counter accordingly, even in the absence of "inc". This is the observed behavior starting from PennController 1.7

Example:

[js try=”data” highlight=”9″]AddTable( “myTable” ,
“Group,Button\n”+
“A,Hello\n”+
“B,World”
);

Sequence(“counter”, “trial”);

SetCounter(“counter”, “inc”, 1);

Template( “myTable” , row =>
newTrial( “trial” ,
newButton( “greetings” , row.Button )
.print()
.wait()
)
);[/js]

Increments the counter as soon as the experiment starts running. Since we use a table defining two groups (A and B) the button will read Hello or World every other time the experiment is run (try running it multiple times without clicking the button).