How do i randomize a subset of text in a question? | XM Community
Solved

How do i randomize a subset of text in a question?

  • 1 February 2024
  • 14 replies
  • 114 views

Badge +1

Community,

I am trying to create a list experiment that looks like the following:

 

“Report how many of the items are true for you:

  1. A
  2. B
  3. C
  4. D

How many items are true for you?”

 

The answer provided would be in a text box. I want to randomize the order of the items in the list without manually creating different questions. Is there a way to do this?

icon

Best answer by TomG 4 February 2024, 19:28

View original

14 replies

Userlevel 5
Badge +12

Hi @TaylorO You can use choice randomization for your use case.

Badge +1

@omkarkewat 

From what I am seeing, choice randomization is only available when the list items are choices. Because I want my response to be a text box, the choice randomization is not popping up for selection at all.

Userlevel 5
Badge +12

@TaylorO I’m trying to understand your use case.


Q1. Report how many of the items are true for you (Multiple select):

  • A
  • B
  • C
  • D

Q2. How many items are true for you?

       Open entry text box (it will consist of the selected choices from Q1 and it should be in a random order)

 

Is my understanding correct? If yes, then can you explain how did you bring the selected choices in an entry text box and will the respondent select the choices from an entry text box?

 

Badge +1

It would be all in one question. The list items are not multiple choice, just text.

 

Q1. Report how many of the items are true for you. Don’t report which items, just HOW MANY:”

  • A
  • B
  • C
  • D

How many items are true for you? (1-4)

       Open entry text box (where respondents can enter the digits 1-4)

Userlevel 5
Badge +12

@TaylorO Ohhh okay got it!
This will require a bit of manual work as well as this solution is without Javascript.

STEP 1:

Create 4 embedded data. You can name it according to your wish and the value will the one that you want to display in the question text list.

STEP 2: Create as many as different combinations possible by just changing the order of the values. Please refer below images.

STEP 3: Insert all these 4 groups inside a randomizer and keep its value as 1 and tick off the ‘evenly present elements’ box for fair randomization. This will ensure that it chooses one combination (group) at a time to a respondent. There will be 4 random combinations, you can create as many as you like.

STEP 4: Pipe text all the 4 embedded data in your question text in a list format (as you require).


Your use case could be possible by JS as well but if you want to do it without JS you can try this method.

Badge +1

@omkarkewat  Thank you! Do you know how to do it with JS? 

I want to do all possible combinations, which is a lot since I have multiple questions like this and some with more than 4 items.

Userlevel 7
Badge +38

@TaylorO I think there is an easier solution for you. If you make the one question it’s own block the randomization can be much less laborious. It could even be within a larger block if a back button is important to you using advanced randomization.

 

  • Create this one question with 6 questions - 5 text/graphic and then 1 text box question type
  • Use the block editor to randomize questions 2-4

 

You can use Look & Feel to decrease the space between questions (see this post).

 

 

 

Badge +1

@omkarkewat This was actually the first thing I tried! But even with the compact spacing, the items are too far apart. I may just have to go the manual route.

Userlevel 7
Badge +27

@TaylorO:

Add a multiple choice question where the list items are the choices before your text entry question (on the same page). Randomize the choices and add this JS:

Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery(this.questionContainer);
q.find(".QuestionBody").hide();
q.find(".QuestionText").css("padding-bottom","0px");
var list = q.find("ul.list").css("margin-bottom","0px");
q.find("label.SingleAnswer>span").each(function() { list.append("<li>"+this.innerHTML+"</li>"); });
});

Add this HTML to the bottom of the question text:

<ul class="list"></ul>

 

Badge +1

@TomG I added the JS and the HTML, but the list is now not displaying at all.

Userlevel 7
Badge +27

@TomG I added the JS and the HTML, but the list is now not displaying at all.

Can you post a public block preview link of your question?

Badge +1

@TomG 

https://albany.az1.qualtrics.com/jfe/preview/previewId/f6985df2-a584-49ac-aa4b-ad95d516b58f/SV_1ImRaUKEZ9YI0Au/BL_5w48Ur6GOVsnDue?Q_SurveyVersionID=current

 

It is only displaying the second question.

Userlevel 7
Badge +27

You added the <ul> html to the wrong question. It should be added the multiple choice question text, not the text entry question text.

Badge +1

@TomG That worked, thank you!!

Leave a Reply