Questionnaire with questions on the same page

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

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #5611
    Jeremy
    Keymaster

    Use .failure, like this:

    newButton("next", "Next")
        .print()
        .wait( test.failure( 
            newText("Please answer all the questions").print() 
        ) )

    Jeremy

    #5612
    ReaToth
    Participant

    Thank you for your help and quick replies.

    Andrea

    #10462
    martaponciano
    Participant

    Hi 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

    #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

    #10467
    martaponciano
    Participant

    Hi 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,
    Marta

    #10470
    martaponciano
    Participant

    Hi 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.
    Marta

    #10471
    Jeremy
    Keymaster

    Hi 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

    #10472
    martaponciano
    Participant

    Hi Jeremy,
    Thanks a lot! That worked wonderfully.

    Marta

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.