Reply To: Questionnaire with questions on the same page

PennController for IBEX Forums Support Questionnaire with questions on the same page Reply To: Questionnaire with questions on the same page

#5435
Jeremy
Keymaster

Hello Andrea,

Since you basically want to repeat the same series of commands multiple times, you can create a function that takes your number/question as an input and outputs the commands, like this:

question = (number,text) => [
    newText("Question-"+number, text)
    ,
    newScale("Rating-"+number, "Strongly Disagree",  "Disagree", "Neither Agree or Disagree", "Agree", "Strongly Agree")
        .log()
        .labelsPosition("top")  
        .before( getText("Question-"+number) )
        .size("auto")
        .print()
]

Once this is in place, you can use it like this:

Template("wbsi.csv", variable =>
  newTrial("WBSI",
    ...question(variable.Number1, variable.Question1)
    ,
    ...question(variable.Number2, variable.Question2)
    ,
    ...question(variable.Number3, variable.Question3)
    ,
    newButton("next", "Next")
        .print()
        .wait()
  )
)

Jeremy