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

#5468
Jeremy
Keymaster

Hello Andrea,

I wrote my message under the assumption that you had multiple Number* and Question* columns in your table, and that for each row of your table, you wanted to print a new form containing as many questions as you have columns in your table.

I suspect that it was a misunderstanding though, and that what you want to do is create a single form using multiple rows from your table, which contains a single Number and a single Question columns. There is no straightforward way of doing exactly this using PennController’s table+Template method, as it was designed to create multiple trials for your experiment, all based on the same template but filling the variable values by looking up a table.

If all you have in your wbsi.csv table is a list of 15 rows with a Number column going from 1 to 15, and a Question column listing your different questions, you could do this instead:

1. Create a file named wbsiQuestions.js in your Controllers folder and set a variable there to contain an array of your questions, like this (only two questions in this example—add the other ones, and don’t forget the line-ending commas):

var wbsiQuestions = [
  "How do you feel about cheating?",
  "How do you feel about skipping class?"
];

2. Keep the definition of the question function above in your main script file, and do this:

newTrial("WBSI",
    ...wbsiQuestions.map( (v,i) => question(i,v) )
    ,
    newButton("next", "Next")
        .print()
        .wait()
)

Jeremy