Reply To: Shuffling audio and text elements consistently

PennController for IBEX Forums Support Shuffling audio and text elements consistently Reply To: Shuffling audio and text elements consistently

#9622
laiamt
Participant

Hi Jeremy,
Thanks a lot!
This works perfectly. However, I’ve tried to minimally change your code to embed it in a template. When I do this, the sentences get printed twice; the first time vertically and not necessarily in the appropriate order. In addition, all the items of the trial are played in the same order (either all audio1 before all audio2, or the other way round).
I’ve tried removing print() after newCanvas(“frases”, 800, 400), but then the order of the audios and texts is not always consistent. Any tips on how to solve this? Apologies if this is too much to ask.

Link: https://farm.pcibex.net/r/sZHLPW/

Template("items.csv", row =>
newTrial("practice1,
         newText("context_practice1",row.context)
        .print()
,
    newButton("go", "go")
       .print()
        .wait()
        ,

    oneFirst = (Math.random()>=0.5)
    ,
    newAudio("audio1", row.file_oi),
    newAudio("audio2", row.file_eh),
    newText("sentence1", row.sentence_oi),
    newText("sentence2", row.sentence_eh)
    ,
    newCanvas("frases", 800, 400).print() //I've tried removing this 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
)