PennController for IBEX › Forums › Support › Conditional trial
Tagged: #conditional #global_variable
- This topic has 2 replies, 2 voices, and was last updated 3 years, 6 months ago by
nasimbhmn.
-
AuthorPosts
-
April 13, 2022 at 7:27 pm #8047
nasimbhmnParticipantHi 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() );April 14, 2022 at 4:45 pm #8055
JeremyKeymasterHi,
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 callwaiton the appropriate one depending on the value of the Var elementJeremy
April 15, 2022 at 9:55 am #8058
nasimbhmnParticipantAhh thanks for the explanation and for your prompt answer.
Best, Nasim
-
AuthorPosts
- You must be logged in to reply to this topic.