Conditionals/display logic

PennController for IBEX Forums Support Conditionals/display logic

This topic contains 2 replies, has 2 voices, and was last updated by Avatar August 4 weeks, 1 day ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6165
    Avatar
    August
    Participant

    Hi Jeremy:

    I wish to display different tasks based on participants’ answers to their answers to the previous question. For instance, for people who answered ‘No’ to the question, they can continue to the next trial, but for people whose answer is ‘No’, I want to have them to do a follow-up task before going to the next trial. Is that possible?

    Thanks so much!

    Best wishes,
    August

    #6167
    Jeremy
    Jeremy
    Keymaster

    Hi August,

    Yes, it is possible. You’ll have to use a global Var element to store and retrieve the participant’s answer to the previous trial. Then depending on its value you either run the full next trial, or you skip over it. Here’s a basic example:

    newTrial(
        newText("How many inches in a foot?").print()
        ,
        newScale("answer", '10','11','12','13','14').button().print().wait()
        ,
        newVar("inches").global().set(getScale("answer"))
    )
    
    newTrial(
        getVar("inches").test.is(12).failure(
            newText("How many centimeters in a meter?").print()
            ,
            newScale("answer", '10','100','1000').button().print().wait()
                .test.selected(100).success( newText("Good job!").print() )
                .failure( newText("Oh well, better luck next time").print() )
            ,
            newButton("Next").print().wait()
        )
    )
    
    newTrial(
        newText("This test is over!").print()
        ,
        newButton().wait()
    )

    Let me know if you have questions

    Best,
    Jeremy

    #6178
    Avatar
    August
    Participant

    Thanks so much!! This is super helpful!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.