Conditional trial

PennController for IBEX Forums Support Conditional trial

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8047
    nasimbhmn
    Participant

    Hi Jeremy,

    I’m trying to change the content of a trial based on participants’ answer to a preceding trial (Their answer will be stored in a global variable called “preference”). The second trial works well when the condition getVar("preference").test.is("no_prep") is successful, but in case of failure it cannot play the video labeled “28e”. Could you please help me find the problem? I also tried to use different labels for videos in each condition, but it didn’t help.

    newTrial("construction",
        newText("no_prep", "Sentence1")
            .css({"line-height": "2em"})
            .print()
        ,
        newText("prep", "Sentence2")
            .css({"line-height": "2em"})
            .print()
        ,
        newScale("prep_choice", getText("no_prep"), getText("prep"))
            .vertical()
            .print()
            .wait()
            .log()
        ,
        newVar("preference").global().set(getScale("prep_choice"))
        ,
        newText("<p>Press spacebar to continue</p>").center().print(),
        newKey(" ").wait()
    );
    
    newTrial("example",
        newVideo("28b", "intro_28b.mp4")
            .size("auto", 480) 
            .center()
            .print()
            .disable(0.01)
        ,
        newText("continue1", "<p>Press spacebar to play the video</p>").center().print()
        ,
        newKey(" ").wait()
        ,
        getText("continue1").remove()
        ,
        getVideo("28b")
            .play()
            .wait("first")
        ,
        newText("continue2", "<p>Press spacebar to continue</p>").center().print(),
        newKey(" ").wait()
        ,
        getVideo("28b").remove()
        ,
        getText("continue2").remove()
        ,
        getVar("preference").test.is("no_prep")
            .success(
                newVideo("28e", "intro_28e.mp4")
                .size("auto", 480) 
                .center()
                .print()
                .disable(0.01)
                )
            .failure(
                newVideo("28e", "intro_28e_prep.mp4")
                .size("auto", 480) 
                .center()
                .print()
                .disable(0.01)
                )
        ,
        newText("continue3", "<p>Press spacebar to continue</p>").center().print(),
        newKey(" ").wait()
        ,
        getText("continue3").remove(),
        
        getVideo("28e")
            .play()
            .wait("first")
        ,
        newText("continue4", "<p>Press spacebar to continue</p>").center().print()
        ,
        newKey(" ").wait()
    );
    #8055
    Jeremy
    Keymaster

    Hi,

    You might be interested in the explanations on this page

    Your code creates two Video elements both named "28e", so when PennController creates the second one, it has to rename it to give it a unique name. You will need to give a different name to each Video element, and accordingly call wait on the appropriate one depending on the value of the Var element

    Jeremy

    #8058
    nasimbhmn
    Participant

    Ahh thanks for the explanation and for your prompt answer.

    Best, Nasim

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.