PennController for IBEX › Forums › Support › Shuffling audio and text elements consistently › Reply To: Shuffling audio and text elements consistently
October 25, 2022 at 4:47 pm
#9618
![](https://www.pcibex.net/wp-content/uploads/2018/10/IMG_8365-e1540835663655-150x150.jpg)
Keymaster
Hi Laia,
You could inject some plain javascript into your code to conditionally reference the first vs the second sentence:
newTrial("practice", oneFirst = (Math.random()>=0.5) , newAudio("audio1", "1fishSquareTank.mp3"), newAudio("audio2", "2fishRoundTank.mp3"), newText("sentence1", "The fish swims in a tank which is perfectly square."), newText("sentence2", "The fish swim in a tank which is perfectly round.") , newCanvas("frases", 800, 400).print() , getText(oneFirst?"sentence1":"sentence2").print( 0,0,getCanvas("frases")), getAudio(oneFirst?"audio1":"audio2").play().wait() , getText(oneFirst?"sentence2":"sentence1").print(400,0,getCanvas("frases")), getAudio(oneFirst?"audio2":"audio1").play().wait() , newSelector("choice") .add( getText("sentence1") , getText("sentence2") ) .log() .wait() ) .log("startWith", oneFirst?1:2) // log which sentence came first
Jeremy