Randomizing groups of questions within a block | XM Community
Skip to main content
Solved

Randomizing groups of questions within a block


Forum|alt.badge.img+2
  • Level 2 ●●
  • 28 replies

I have the following setup in Qualtrics: 

Statement 1

Question 1.1

Question 1.2 

Question 1.3 

Question 2.1 

Question 2.2

Question 2.3 

Question 3.1

Question 3.2

Question 3.3

 

I have them all in one block because all the questions needs to be displayed in one page. 

 

I want to randomize questions 1, 2 and 3. 

This means Q1.1, Q1.2 and Q1.3 will appear together always. Similarly Q2.1, Q2.2 and Q2.3 will appear together. And finally, Q3.1, Q3.2 and Q3.3 will appear together. But the sequence in which the question groups (Q1, Q2 and Q3)  appear will vary. 

For example one respondent will see the question sequence as below:

Statement 1

Question 2.1

Question 2.2 

Question 2.3 

Question 1.1 

Question 1.2

Question 1.3 

Question 3.1

Question 3.2

Question 3.3

 

Please let me know. 

 

Thanks, 

O

Best answer by TomG

@OBh,

Use Advanced Randomization so that Q1, Q2, and Q3 are randomly displayed immediately after “Statement”.

Add a span with a class to associate each of the follow-up questions with the parent question. For example:

<span class="Q1">(1) I agree with the statement</span>

Add JS to the parent questions to move their follow-up questions immediately after. For example:

Qualtrics.SurveyEngine.addOnload(function() {
	var q = jQuery(this.questionContainer);
	jQuery(".Q1").each(function() { jQuery(this).closest(".QuestionOuter").insertAfter(q); });
});

 

View original

11 replies

  • Level 4 ●●●●
  • 194 replies
  • March 7, 2025

Can you show how did you set the question. Images will be more beneficial.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5909 replies
  • March 7, 2025

@OBh,

Question randomization alone can’t do this. You could combine question advanced randomization together with JS that moves questions to accomplish it.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 7, 2025

@TomG sorry, I do not know what JS to use for this. I can do advanced randomization but that does not allow grouping. So, it would be helpful if you could elaborate. 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 7, 2025

@jbk 

 

Please see the image below, they are all multiple choice questions. 

 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5909 replies
  • Answer
  • March 7, 2025

@OBh,

Use Advanced Randomization so that Q1, Q2, and Q3 are randomly displayed immediately after “Statement”.

Add a span with a class to associate each of the follow-up questions with the parent question. For example:

<span class="Q1">(1) I agree with the statement</span>

Add JS to the parent questions to move their follow-up questions immediately after. For example:

Qualtrics.SurveyEngine.addOnload(function() {
	var q = jQuery(this.questionContainer);
	jQuery(".Q1").each(function() { jQuery(this).closest(".QuestionOuter").insertAfter(q); });
});

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 7, 2025

@TomG 

Thanks for the suggestion. I will use this to try and build a working solution. 

Thanks, 

O


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 9, 2025

@TomG 

 

Thanks it worked.

I was a mistake of using the same class to both statements .

So I used <span class="Q1_1"> and <span class="Q1_2"> and then used the code you have provided :
 

Qualtrics.SurveyEngine.addOnload(function() {
    var q = jQuery(this.getQuestionContainer());


    jQuery(".Q1_1").each(function() { 
        jQuery(this).closest(".QuestionOuter").insertAfter(q);
        q = jQuery(this).closest(".QuestionOuter"); 
    });

    jQuery(".Q1_2").each(function() { 
        jQuery(this).closest(".QuestionOuter").insertAfter(q);
        q = jQuery(this).closest(".QuestionOuter"); 
    });
});

Just in case anyone else is having trouble with such problems. 


 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 9, 2025

One more thing. I am unsure if it is possible in Qualtrics. 

My Question is: Suppose the main sequence of questions in the survey builder is: 

Q1: Statement 1: Local food is healthy
Q2: Statement 2: Local food is tasty
Q3: Statement 3: Local food is costly. 

When the randomization of questions groups occur, I want Q1, Q2 and Q3 to have have Statement i:………., where i depends on the position of the statement. Example. suppose after randomization the question sequence comes as: Q2,Q1 and Q3. 
So I wish the preview would be: 


Statement 1: Local food is tasty
Statement 2: Local food is healthy
Statement 3: Local food is costly. 

I gave it a try to put same class to all three statements Q1, Q2, Q3. 

<span class="statement-label"></span> . But unsure how to implement in JS to dynamically update it based on position. 

Any suggestion would be helpful. 

Thanks, 

O


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5909 replies
  • March 10, 2025
OBh wrote:

@TomG 

 

Thanks it worked.

I was a mistake of using the same class to both statements .

So I used <span class="Q1_1"> and <span class="Q1_2"> and then used the code you have provided :
 

Qualtrics.SurveyEngine.addOnload(function() {
    var q = jQuery(this.getQuestionContainer());


    jQuery(".Q1_1").each(function() { 
        jQuery(this).closest(".QuestionOuter").insertAfter(q);
        q = jQuery(this).closest(".QuestionOuter"); 
    });

    jQuery(".Q1_2").each(function() { 
        jQuery(this).closest(".QuestionOuter").insertAfter(q);
        q = jQuery(this).closest(".QuestionOuter"); 
    });
});

Just in case anyone else is having trouble with such problems. 


 

You could have used the original code and just reversed the question order in advanced randomization.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5909 replies
  • March 10, 2025
OBh wrote:

One more thing. I am unsure if it is possible in Qualtrics. 

My Question is: Suppose the main sequence of questions in the survey builder is: 

Q1: Statement 1: Local food is healthy
Q2: Statement 2: Local food is tasty
Q3: Statement 3: Local food is costly. 

When the randomization of questions groups occur, I want Q1, Q2 and Q3 to have have Statement i:………., where i depends on the position of the statement. Example. suppose after randomization the question sequence comes as: Q2,Q1 and Q3. 
So I wish the preview would be: 


Statement 1: Local food is tasty
Statement 2: Local food is healthy
Statement 3: Local food is costly. 

I gave it a try to put same class to all three statements Q1, Q2, Q3. 

<span class="statement-label"></span> . But unsure how to implement in JS to dynamically update it based on position. 

Any suggestion would be helpful. 

Thanks, 

O

Assuming you are adding it to the previous code:

q.find(".statement-label").function(i) { jQuery(this).text(i+1); });

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 28 replies
  • March 11, 2025

@TomG Thanks for your response. 


Leave a Reply