Sample trial: Text+Response

Next pages: (late) Preliminary remarks on PennController's ontology

Next sample trial: Picture Selection

Setup

Create a new experiment on Ibex. Click on Update from git repo and enter the following URL: https://github.com/PennController/Tutorial.git, then replace master with text-response (all lower case, simple dash) and click on the Sync button. You should see a confirmation message appear below the button, reading Success: N file modified. If you don’t see the message, try clicking again. If it still does not work, reload your Ibex page and try again.

Warning: whenever you click on Sync, the file example_data gets erased and reverts back to the code in the Basics section below.

Basics

Let’s say we are interested in whether colder comes with an entailment that the comparee is cold tout court. Practically, we want to show a sentence that contradicts the potential entailment and ask the participant to report whether it is coherent or not. Here is how your example_data.js file should look like for a very basic implementation (the lines starting with // are comments—they do not have any effect whatsoever but are only here for clarifications when you read the code):

// We will explain this line later
PennController.ResetPrefix(null);

// Use PennController to script your trial
PennController(
    // We create a new text element that we name 'test sentence,' which contains the text of our complex test sentence
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        .print() // This prints the text onto the screen
    ,
    // We create a key element that we name 'answer' and which reacts to any key press on F (coherent) or J (incoherent)
    newKey("answer", "FJ")
        .wait() // This waits for a key press before validation
);

Adding more text

This does the job, but it would probably be better with some instructions.

PennController.ResetPrefix(null);

PennController(
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        .print()
    ,
    // We simply create and print two new text elements
    newText("question", "Does this sentence feel contradictory to you?")
        .print()
    ,
    newText("instruction", "Press F if you think the sentence is coherent, press J if you think it is INcoherent.")
        .print()
    ,
    newKey("answer", "FJ")
        .wait()
);

Aesthetics

As is though, it is hard to visually tell the sentence to evaluate from the instructions. Let’s add some aesthetics:

PennController.ResetPrefix(null);

PennController(
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        .print()
    ,
    newText("question", "Does this sentence feel contradictory to you?")
        .settings.bold() // Boldface
        .print()
    ,
    newText("instruction", "Press F if you think the sentence is coherent, press J if you think it is INcoherent.")
        .settings.italic() // Italics
        .print()
    ,
    newKey("answer", "FJ")
        .wait()
);

And maybe we want to center all of our sentences. We can do it one by one:

PennController.ResetPrefix(null);

PennController(
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        .settings.center() // This one...
        .print()
    ,
    newText("question", "Does this sentence feel contradictory to you?")
        .settings.center() // this one...
        .settings.bold()
        .print()
    ,
    newText("instruction", "Press F if you think the sentence is coherent, press J if you think it is INcoherent.")
        .settings.center() // ... and this one
        .settings.italic()
        .print()
    ,
    newKey("answer", "FJ")
        .wait()
);

Defaults

OR we can do it all at once:

PennController.ResetPrefix(null);

PennController(
    defaultText
        .settings.center() // will add this line immediately after any newText
    ,
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        //.settings.center()
        .print()
    ,
    newText("question", "Does this sentence feel contradictory to you?")
        //.settings.center()
        .settings.bold()
        .print()
    ,
    newText("instruction", "Press F if you think the sentence is coherent, press J if you think it is INcoherent.")
        //.settings.center()
        .settings.italic()
        .print()
    ,
    newKey("answer", "FJ")
        .wait()
);

In fact we can also tell PennController to print any newly created text by default: the text will be automatically printed onto the page below the elements that were added to the page before its creation.

PennController.ResetPrefix(null);

PennController(
    defaultText
        .settings.center()
        .print() // Any text element will be printed upon creation
    ,
    newText("test sentence", "A is colder than B, though A is not cold yet.")
        //.print()
    ,
    newText("question", "Does this sentence feel contradictory to you?")
        .settings.bold()
        //.print()
    ,
    newText("instruction", "Press F if you think the sentence is coherent, press J if you think it is INcoherent.")
        .settings.italic()
        //.print()
    ,
    newKey("answer", "FJ")
        .wait()
);

Exercises

  • make the question appear above the test sentence
  • make wait() a default command for keys
  • add a Press C to continue message and listen for a press on the C key before printing the instruction

Questions

Why is print() not a default… by default?

Because sometimes you may want to make sure some manipulations on the text take effect BEFORE it becomes visible on the screen (e.g., setting its aesthetics). In more complex cases, you may even want to create the text element at some point during the trial, do some actions, and only print the text later on.

Why do I need to give a name to every element? It’s annoying

This is to enforce consistent practices. As your scripts become more complex, you will need to refer back to some (possibly most/all) of the elements you creat. This is only possible if you name your elements. Naming the elements you create also helps making sense of what you’re doing.

Next pages: (late) Preliminary remarks on PennController's ontology

Next sample trial: Picture selection & Audio playback