PennController for IBEX › Forums › Support › Repeat Trial After Feedback
- This topic has 1 reply, 2 voices, and was last updated 4 years, 5 months ago by Jeremy.
-
AuthorPosts
-
April 12, 2020 at 8:41 pm #5036FarzanehParticipant
Hello,
Thank you so much for taking the time to respond to questions in the forum. For my practice trials, I want participants to repeat a trial if they don’t get the answer right. I’ve looked throughout the forum and couldn’t find a similar topic. I’d appreciate it if you could help with how I should modify the script below.
newTrial( newTimer(500) .start() .wait() , newAudio("BeepBeep.mp3") .play() .wait("first") , newTimer(500) .start() .wait() , newAudio("PracSHSR.mp3") .play() , newImage("one", "Man.png") .settings.size(380,380) .settings.css("border", "solid 1px black") , newImage("two", "Boy.png") .settings.size(380,380) .settings.css("border", "solid 1px black") , newImage("three", "Girl.png") .settings.size(380,380) .settings.css("border", "solid 1px black") , newCanvas(1200,400) .settings.add( 0 , 0, getImage("one") ) .settings.add( 400 , 0 , getImage("two") ) .settings.add( 800, 0, getImage("three") ) .print() , getAudio("PracSHSR.mp3") .wait("first") , newSelector() .settings.add(getImage ("one"), getImage ("two"), getImage ("three") ) .keys ("F", "J", "T") .settings.log() .wait() .test.selected(getImage ("two")) .success( newText("Good job!") .settings.center() .print() ) .failure (newText ("Wrong answer. Try again.") .settings.center() .print()) , newTimer(2000) .start() .wait() , newAudio("Beep.mp3") .play() .wait("first") , newTimer(1000) .start() .wait() ) ,
Thank you,
Farzaneh
- This topic was modified 4 years, 5 months ago by Farzaneh.
April 13, 2020 at 3:32 pm #5039JeremyKeymasterHi Farzaneh,
Yeah, PCIbex is not great at handling loops at the moment, I should work on a solution for that. In the meantime, what you can do is first create all the elements you will manipulate at the beginning of your trial, and put the bit that needs to be re-executed upon failure in an array, so you can reference it multiple times, like this:
// We'll refer to this sequence of commands multiple times let launch = [ newTimer(500) .start() .wait() , getAudio("BeepBeep.mp3") .play() .wait() , newTimer(500) .start() .wait() , getAudio("PracSHSR.mp3") .play() , getImage("one") .size(380,380) .css("border", "solid 1px black") , getImage("two") .size(380,380) .css("border", "solid 1px black") , getImage("three") .size(380,380) .css("border", "solid 1px black") , getCanvas("images") .add( 0 , 0, getImage("one") ) .add( 400 , 0 , getImage("two") ) .add( 800, 0, getImage("three") ) .print() , getAudio("PracSHSR.mp3") .wait() , getSelector("choice").enable() ] newTrial( // Create your elements first newAudio("BeepBeep.mp3"), newAudio("PracSHSR.mp3"), newAudio("Beep.mp3") , newImage("one", "Man.png"), newImage("two", "Boy.png"), newImage("three", "Girl.png") , newCanvas("images", 1200 , 400) , newText("positiveFeedback", "Good job!"), newText("negativeFeedback", "Wrong answer. Try again.") , newSelector("choice") , // Now execute the sequence of commands above ...launch , getSelector("choice") .add(getImage ("one"), getImage ("two"), getImage ("three") ) .keys ("F", "J", "T") .log() // Only release 'wait' if correct choice .wait( getSelector("choice").test.selected( getImage("two") ) .failure( // If wrong choice... getText("negativeFeedback") .center() .print() , newTimer(2000).start().wait() , getText("negativeFeedback").remove() , // Make sure to disable selection again getSelector("choice").disable() , // And take the Canvas off the page getCanvas("images").remove() , // Now re-execute the sequence of commands above ...launch ) ) .disable() , getText("positiveFeedback") .center() .print() , newTimer(2000) .start() .wait() , getAudio("Beep.mp3") .play() .wait("first") , newTimer(1000) .start() .wait() )
Let me know if you have questions
-
AuthorPosts
- You must be logged in to reply to this topic.