Reply To: Randomizing trials, with 1/5 of trials followed by a comprehension question

PennController for IBEX Forums Support Randomizing trials, with 1/5 of trials followed by a comprehension question Reply To: Randomizing trials, with 1/5 of trials followed by a comprehension question

#9641
Jeremy
Keymaster

Hi,

Some elements are missing from the pieces of code you posted (how color_order_label, leftColor, centerColor, rightColor and getImageEmotion are defined, where/whether createColorGroup is called elsewhere) but if I understand your question correctly, you should be able to do something like this:

function createColorGroup(int) {
    var bugba = ["blue", "green", "black", "bugba"];
    var gbuba = ["green", "blue", "black", "gbuba"];
    var bagbu = ["black", "green", "blue", "bagbu"];
    var gbabu = ["green", "black", "blue", "gbabu"];
    var babug = ["black", "blue", "green", "babug"];
    var bubag = ["blue", "black", "green", "bubag"];
    
    var groups = [bugba, gbuba, bagbu, gbabu, babug, bubag];
    
    return groups[int]; 
}
color_group = createColorGroup(Math.round(6*Math.random()))
leftColor = color_group[0]
centerColor = color_group[1]
rightColor = color_group[2]
color_order_label = color_group[3]

Template( "emoMusicGroupedPracticeV2.csv" ,
  row => newTrial("PracticeEmoMusic",
    newAudio(row.audiofile).center().print().wait() 
    ,
    newText("Q", "<p>Whose face matches the music?</p>").center().css("font-size", "1.5em").print()
    ,
    newSelector("eugenies").once().frame("dashed 0px white")
    ,
    defaultImage.cssContainer({border:"solid 2px black","background-color":"white"})
    ,
    newImage(String(getImageEmotion(row.leftImage)), leftColor+row.leftImage),
    newImage("calmImage", centerColor + "calmnolabel.jpg"),
    newImage(String(getImageEmotion(row.rightImage)), rightColor+row.rightImage)
    ,
    newCanvas("labels", 600, 200)
      .add("center at 18%", "middle at 50%", getImage(String(getImageEmotion(row.leftImage))))
      .add("center at 50%", "middle at 50%", getImage("calmImage"))
      .add("center at 82%", "middle at 50%", getImage(String(getImageEmotion(row.rightImage))))
      .color("yellow")
      .cssContainer("border", "solid 2px black")
      .center()
      .print()
    // etc.
  )
  .log("id", getVar("subjID"))
  .log("color_group", color_order_label)
)

Jeremy