PennController for IBEX › Forums › Support › Questionnaire with questions on the same page
- This topic has 22 replies, 5 voices, and was last updated 1 year, 5 months ago by martaponciano.
-
AuthorPosts
-
June 9, 2020 at 1:22 pm #5611JeremyKeymaster
Use .failure, like this:
newButton("next", "Next") .print() .wait( test.failure( newText("Please answer all the questions").print() ) )
Jeremy
June 9, 2020 at 2:09 pm #5612ReaTothParticipantThank you for your help and quick replies.
Andrea
April 24, 2023 at 8:14 am #10462martaponcianoParticipantHi Jeremy,
I’ve designed an experiment which includes a questionnaire. The questionnaire must display all the questions on the same page. I am using scale as a measurement for responses and I have created a file named wbsiQuestions.js in my Controllers folder in order to set a variable there to contain the array of questions. Basically I am using the code you wrote down from messages above and it works perfectly well. Thank you very much for that! However, I’d love to know how to randomize the questions (that is the scale’s labels)? May I ask how to do that? Do I need a new Canvas element (containing my Scale+Test elements) and a Selector element? Also, I’d love to know how to keep track of the presentation order of all the questions after we randomize the presentation order. It would be great to have them in the results file.
So far I have used this code:
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 ) )
Thanks a lot.
Best wishes,Marta
April 24, 2023 at 9:03 am #10465JeremyKeymasterHi 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
April 24, 2023 at 12:01 pm #10467martaponcianoParticipantHi Jeremy,
Thank you for your quick reply. Exactly, the “question” from my code is the one defined in that message. What I meant was option 3. Your code works great!
Thank you again,
MartaApril 25, 2023 at 6:38 am #10470martaponcianoParticipantHi Jeremy,
I have a follow-up question. May I ask if I can get the actual questions in the array printed in the results file after Question-0; Question-1? It would be very much appreciated.
Thanks a lot.
MartaApril 25, 2023 at 8:59 am #10471JeremyKeymasterHi Marta,
My bad, I thought the content of the Text elements would be logged, but that’s not the case. One thing you could do is redefine the
question
function like this:question = (number,text) => newScale("Rating-"+number, "Strongly Disagree", "Disagree", "Neither Agree or Disagree", "Agree", "Strongly Agree") .log() .labelsPosition("top") .before( newText(text).log() ) .size("auto") .print();
The Text elements will be reported in the results file in the order in which they were printed, so that the Text element of the first reported row will correspond to the Scale element named Rating-0, and so on. The content of the Text elements will be found in the PennElementName column of their corresponding rows
Jeremy
April 25, 2023 at 9:31 am #10472martaponcianoParticipantHi Jeremy,
Thanks a lot! That worked wonderfully.Marta
-
AuthorPosts
- You must be logged in to reply to this topic.