PennController.TemplateGlobal Commands

(PennController.FeedItems has become deprecated since version 1.0)

PennController.Template( row => PennController() )

or PennController.Template( table , row => PennController() )

or PennController.Template( row => ["controllername", options, "controllername", options, ...] )

or PennController.Template( table , row => ["controllername", options, "controllername", options, ...] )

or PennController.Template( row => ["label", "controllername", options, "controllername", options, ...] ) (since PennController 1.4)

or PennController.Template( table , row => ["label", "controllername", options, "controllername", options, ...] ) (since PennController 1.4)

Generates Ibex items from a table. See this page to learn how to use it. You can have as many PennController.Template as you want (which is helpful if you use different trial templates).

You can pass the name of the table you want to use as a string, or use PennController.GetTable. If you do not explicitly specify a table, PennController.Template will use the table whose name comes first in the alpha-numerical order (if any—if you added only one table, it will automatically use that table).

The argument of Template is a function: you can use arrow functions, as illustrated in this documentation, or old-style functions: PennController.Template( function (row) { return PennController( ... ); } ).

The variable (named row here, but you could also name it item, or however pleases you) is iteratively fed with the content of each row of the table (modulo filtering, see PennController.GetTable().filter). You retrieve the value of a given column with row.columnName or row["columnName"] (use the latter if you column’s name contains special characters, like spaces, commas, periods or dashes).

The argument function can directly return PennController(), defining a PennController template for the trials to be generated. It can also return an array of Ibex item-elements: in this case, it should follow the same format as the definition of a standard Ibex item, modulo the label name (see Ibex’s documentation manual).

Examples:

PennController.AddTable( "mytable" ,
    "Type,Sentence,TargetPicture,CompetitorPicture\n"+
    "Test,This is a square,square.png,triangle.png\n"+
    "Filler,This is a triangle,triangle.png,pear.png"
);

PennController.Template( "mytable" ,
    row => PennController( row.Type ,
        newText("sentence", row.Sentence)
            .print()
        ,
        newSelector("choice")
        ,
        defaultImage
            .settings.size(200,200)
            .settings.selector("choice")
        ,
        newCanvas( "images", 500, 200 )
            .settings.add(   0, 0, newImage("target", row.TargetPicture)     ) 
            .settings.add( 300, 0, newImage("target", row.CompetitorPicture) ) 
            .print()
        ,
        getSelector("choice")
            .shuffle()
            .wait()
    )
);

Generates trials labeled according to the Type column of the table, showing a sentence whose text is retrieved from the Sentence column of the table, and two pictures side by side retrieved from the TargetPicture and CompetitorPicture columns.

PennController.AddTable( "mytable" ,
    "Type,Sentence\n"+
    "Filler,The cat that is chasing the mouse runs fast\n"+
    "Test,The mouse that the cat is chasing runs fast"
);

PennController.Template( "mytable" ,
    row => [
        "DashedSentence", {s: row.Sentence},
        "PennController", PennController(
            newText("question", "How natural did you find this sentence?")
                .print()
            ,
            newScale("natural", 7)
                .settings.before( newText("left", "Completely unnatural") )
                .settings.after( newText("right", "Completely natural") )
                .print()
                .wait()
        )
    ]
);

Generates two-screen trials, the first screen using the native Ibex DashedSentence with the value from the Sentence column passed as its s parameter, the second screen using PennController to show a naturalness scale.