Hiding a question from participants | XM Community
Question

Hiding a question from participants

  • 9 February 2024
  • 5 replies
  • 187 views

Badge +1

Hi.

I’m currently making a survey for an experiment where participants are prompted to click on the Q key for Yes answers and P key for No answers.

 

I figured out the code to do this, but is it possible to make the actual question and answer options portion invisible. That way the only thing they see is a white screen and they can just click to answer the question.

 

Please let me know :)


5 replies

Userlevel 3
Badge +11

There are a few options. You could use a survey flow randomizer or you could assign embedded data (show or no show) and then use that piece of embedded data in display logic for the question(s).

Userlevel 3
Badge +11

Hi @tru_gamble, You can achieve this using JavaScript to hide the elements you want to be invisible.

Use JavaScript to hide the question and answer options. You can do this by targeting the HTML elements corresponding to the question and answer options and setting their display property to "none".

Implement a key event listener in JavaScript to capture when participants press the Q or P keys. When the keys are pressed, you can trigger the corresponding action (e.g., recording a Yes or No response).

Since participants won't see the question and answer options, you should provide clear instructions at the beginning of the survey informing them to use the Q key for Yes answers and the P key for No answers.

Here's a simplified example of how you can achieve this using JavaScript:

Copy code
Qualtrics.SurveyEngine.addOnload(function() {
    // Hide question and answer options
    document.getElementById('QuestionID').style.display = 'none';
    // Replace 'QuestionID' with the actual ID of your question
    
    // Add key event listener
    document.addEventListener('keypress', function(event) {
        if (event.key === 'q' || event.key === 'Q') {
            // Participant pressed Q key
            // Add code to record Yes response
        } else if (event.key === 'p' || event.key === 'P') {
            // Participant pressed P key
            // Add code to record No response
        }
    });
});

Replace 'QuestionID' with the actual ID of your question element. Additionally, add code within the key event listener to record the participant's responses accordingly.

Badge +1

@Umang Upadhyay When you say question ID do you mean the question title or block title…. or something else? Also would I putts java script into the question it self?

Userlevel 6
Badge +21

Good suggestion @Umang Upadhyay, it should work.

@tru_gamble, the Question ID serves as a system-generated identifier to differentiate between questions. To view your question ID:

1. Click on 'Tools'.
2. Select 'Auto number questions'.
3. Choose 'QID'.
4. Your question ID will be displayed instead of the question number at the top left of the question box, appearing as QID1, QID2, and so forth.

For adding JavaScript, please refer to the link provided for further guidance.

https://www.qualtrics.com/support/survey-platform/survey-module/question-options/add-javascript/

Badge +1

@Sachin Nandikol 

Thank you very much!

This worked to make my question invisible, but now I am having trouble with the code.

I am not familiar with Java Script (only python). This is what I originally had (and it worked):

Qualtrics.SurveyEngine.addOnload(function()

{

    var qobj = this;

jQuery(document).keypress(function(event) {

     var key = event.key.toUpperCase();

     if(key == "Q" || key == "P") {

         jQuery(this).trigger("mouseup");

         if(key == "Q") qobj.setChoiceValueByRecodeValue(1,true);

         else qobj.setChoiceValueByRecodeValue(2,true);

    qobj.clickNextButton();

     }

});

 

});

 

Qualtrics.SurveyEngine.addOnReady(function()

{

    /*Place your JavaScript here to run when the page is fully displayed*/

 

});

 

Qualtrics.SurveyEngine.addOnUnload(function()

{

    /*Place your JavaScript here to run when the page is unloaded*/

 

});

 

How would I integrate this into the the code @Umang Upadhyay had suggested?

 

Leave a Reply