Reply To: Conditional trials sequence

PennController for IBEX Forums Support Conditional trials sequence Reply To: Conditional trials sequence

#5215
Jeremy
Keymaster

Hi Lynn,

Unfortunately this kind of conditional sequence of trials is a feature that is not well supported in (PC)Ibex. The problem is that the sequence of trials is computed once, as soon as one opens the experiment’s page. Since you have to deal with a constant sequence of trials, one trick is to dynamically change the content of those trials.

For example, you could do that:

PennController.ResetPrefix(null)

Sequence( "intro" , randomize(startsWith("T")) , "end" )

newTrial( "intro" , 
  newVar("chosenletter", "").global()
  ,
  newScale("letter", "A","B","C")
    .labelsPosition("left")
    .before( newText("Choose a letter:") )
    .print()
    .wait()
    .setVar("chosenletter")
)

AddTable("myTable", `item,questionAB,correctAnswerAB,questionC,correctAnswerC
1,What is the result of 2+2?,4,What is the result of 2*2?,4
2,What is the result of 3+3?,6,What is the result of 3*3?,9`)

trialAB = row => [
  newText(row.questionAB).print()
  ,
  newTextInput("inputAB", "")
    .print()
    .once()
    .wait()
    .test.text(row.correctAnswerAB)
    .success( newText("Good job!").print() )
    .failure( newText("Nope, sorry").print() )
  ,
  newTimer(1000).start().wait()
]

trialC = row => [
  newText(row.questionC).print()
  ,
  newScale("sliderC", '1', '2', '3', '4', '5', '6', '7', '8', '9', '10')
    .labelsPosition("top")
    .print()
    .once()
    .wait()
    .test.selected(row.correctAnswerC)
    .success( newText("Good job!").print() )
    .failure( newText("Nope, sorry").print() )
  ,
  newButton("Continue").print().wait()
]

Template( "myTable" , row => 
  newTrial( "T"+row.item ,
    getVar("chosenletter").test.is("C")
      .success( ...trialC(row) )
      .failure( ...trialAB(row) )
  )
)

In this example the AB and C trials are almost the same, but of course you can code very different structures. Just keep in mind that all the commands of both the AB and C versions will technically be included in the trial, which means you should use unique names for your elements considering both variants. If you have two elements that share the same name, one in the AB and the other in the C version, then you will get unreliable behavior.

Jeremy