Reply To: re-taking randomized item order

PennController for IBEX Forums Support re-taking randomized item order Reply To: re-taking randomized item order

#7668
Jeremy
Keymaster

Dear Jones,

You will have to write some custom javascript for that. The idea is to store the audio references in an array that you shuffle, and use that array to generate both types of trials. Then you can run the trials themselves in their original order, since the references will have been randomized anyway

Assuming you are using a CSV file with a column named Audio that references filenames, your code should look like this:

Sequence("start","Item","ItemQ")

newTrial("start", newButton("Start").print().wait() )

audios = []     // audios will reference the audios in a randomized order for simple playback
audios2 = []    // audios2 will ultimately be a copy of audios
// Create dummy trials to browse the table and feed then shuffle audios
Template( row => newTrial( audios.push(row.Audio),fisherYates(audios) ) )

// Now create the Item trials reading the audio references from audios
audio = ""
Template( row =>
    newTrial( "Item",
        audio = audios.shift(), // Extract next entry from audios
        audios2.push(audio)     // Place it in audios2
        ,
        newAudio( audio ).play().wait() // Play back the audio
        ,
        newButton( "Next" ).print().wait()
    )
    .log("audio", audio)    // Log which audio was played
)

// Now create the ItemQ trials reading the audio references from audios2
audio = ""
Template( row =>
    newTrial( "ItemQ",
        audio = audios2.shift() // Extract next entry from audios2
        ,
        newAudio( audio ).play().wait() // Play back the audio
        ,
        newTextInput("answer", "What did it say?").print().log()
        ,
        newButton( "Next" ).print().wait()
    )
    .log("audio", audio)
)

Jeremy