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

#10465
Jeremy
Keymaster

Hi Marta,

Is the question from your code the one defined in this message? And by randomizing “the questions (that is the scale’s labels)”, do you mean that you want to randomize “Strongly Disagree”, “Disagree”, “Neither Agree or Disagree”, “Agree” and “Strongly Agree”? If so, do you want to randomize the labels for every single question (option 1), or do you want to randomize the labels once at the beginning of the trial and use that order for all the questions in the trial (option 2)? Or do you just want to randomize the questions in the array, but keep the labels constant (option 3)?

Option 1:

const labels = ["Strongly Disagree",  "Disagree", "Neither Agree or Disagree", "Agree", "Strongly Agree"];
question = (number,text) => {
  fisherYates(labels);
  return [
    newText("Question-"+number, text)
    ,
    newVar("labels-"+number, labels.join(";")).log() // log the order of the labels for this question
    ,
    newScale("Rating-"+number, ...labels)
        .log()
        .labelsPosition("top")  
        .before( getText("Question-"+number) )
        .size("auto")
        .print()
  ];
}

var test;
newTrial("WBSI",
    ...wbsiQuestions.map( (v,i) => {
        if (i==0) test = getScale("Rating-"+i).test.selected();
        else test = test.and( getScale("Rating-"+i).test.selected() );
        return question(i,v);
    })
    ,
    newButton("next", "Next")
        .print()
        .wait( test )
)

Option 2:

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

var test;
newTrial("WBSI",
    fisherYates(labels)
    ,
    ...wbsiQuestions.map( (v,i) => {
        if (i==0) test = getScale("Rating-"+i).test.selected();
        else test = test.and( getScale("Rating-"+i).test.selected() );
        return question(i,v);
    })
    ,
    newButton("next", "Next")
        .print()
        .wait( test )
)
.log( "labels" , labels.join(";") ) // log the order of the labels for this trial

Option 3:

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

var test;
newTrial("WBSI",
    fisherYates(wbsiQuestions)
    ,
    ...wbsiQuestions.map( (v,i) => {
        if (i==0) test = getScale("Rating-"+i).test.selected();
        else test = test.and( getScale("Rating-"+i).test.selected() );
        return question(i,v);
    })
    ,
    newButton("next", "Next")
        .print()
        .wait( test )
)

Jeremy