Conditional logic: show task based on response in previous task

PennController for IBEX Forums Support Conditional logic: show task based on response in previous task

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #10988
    supadhye
    Participant

    Hi Jeremy,

    I need some advice on how to implement conditional logic in ibex. In my experiment, each trial consists of two mandatory and one optional task, and whether the participants see the third optional task depends on how they respond to the first judgement task. The way I have attempted to implement this is to have a global boolean variable that is set to true or false if a particular button is pressed. Subsequently, I use an if-statement to display the contents of the third task. Currently, the code is not working as expected, and I’m not sure whether the variable instantiation or the conditional logic is incorrectly implemented. Below is a version of the code with relevant blocks. I’m still new to ibex, and would appreciate your advice on how to go about this.

    PennController.ResetPrefix(null)

    Sequence(“experimental-trials”)
    Template(“stimuli.csv”, row =>
    newTrial(“experimental-trials”,
    // variable for storing response of first task
    newVar(“show-third”,”).global()

    newSelector(“judgement-buttons”)
    ,
    newCanvas(“judgement-task”,800,600)
    .add(0,10,newText(“ask-judgement”, “What do you think of the sentence you just heard?”).settings.css(“font-size”,”2em”).color(“black”))
    .add(20,200,newButton(“acceptable”,”Sounds good :)”).selector(“judgement-buttons”))
    .add(400,200,newButton(“not-acceptable”,”Doesn’t sound right :(“).selector(“judgement-buttons”))
    .print()
    ,
    getSelector(“judgement-buttons”)
    .once()
    .wait()
    .log()
    ,
    // set value of show-third depending on participant response
    getButton(“not-acceptable”)
    .test.clicked()
    .success(getVar(“show-correction-task”).set(true))
    .failure(getVar(“show-correction-task”).set(false))
    ,
    getCanvas(“judgement-task”).remove()
    ,
    newTimer(“post-judgdment”,3000)
    .start()
    .wait()
    ,
    newCanvas(“pre-repetition”,800,600)
    .add(250,150,newText(“fixation-cross2”, “+”).settings.css(“font-size”,”200px”).color(“blue”))
    .print()
    ,
    getAudio(“audio”)
    .play()
    .wait()
    .remove()
    ,
    getCanvas(“pre-repetition”)
    .remove()
    ,
    newCanvas(“repetition”,1000,1000)
    .add(0,100,newText(“repetition-instruction”,”Repeat the sentence you just heard in the textbox below (Hit ‘Enter’ once you’re done)”).settings.css(“font-size”,”1em”).color(“black”))
    .add(0,200,newTextInput(“type-sentence”, “”).size(600,40).log(“all”) )
    .print()
    ,
    newKey(“Enter”)
    .print()
    .wait(getTextInput(“type-sentence”).testNot.text(“”)
    .failure(newText(“Please type the sentence you just heard in the textbox to continue”).print()))
    ,
    // loop to determine whether to display third task
    (getVar(“show-correction-task”) == true ? [
    newText(“correction-task”,”Please correct the sentence”).settings.css(“font-size”,”1em”).color(“black”)
    .print()
    .wait()
    ] : [//do nothing])
    ))

    Thank you!

    Best,
    Shiva

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.