Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Randomize two sets of answer choices

  • wendyt
  • wendyt's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago - 6 years 7 months ago #157549 by wendyt
Randomize two sets of answer choices was created by wendyt
Dear fellows,

I'm a new LimeSurvey user and would like to see if we can set the radio question with 2 sets of answers. I checked there are ways to completely randomize all choices or partially with fixed order. But I cannot find a way to manage in particular the below:

Set 1:
Strongly agree
Agree
Neutral
Disagree
Strongly disagree
Don't know

Set 2:
Strongly disagree
Disagree
Neutral
Agree
Strongly agree
Don't know

Thank you very much!
Last edit: 6 years 7 months ago by wendyt.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago - 6 years 7 months ago #157552 by Joffm
Replied by Joffm on topic Randomize two sets of answer choices
Hi, wendyt,
maybe there is a way to do this with Javascript.
But here are two ways to do it just out of the box.

1. Create two questions (Q1A and Q1B) with answer options:
Q1A:
1 =Strongly agree
2 =Agree
3 =Neutral
4=Disagree
5=Strongly disagree
9=Don't know

Q1B:
5=Strongly disagree
4=Disagree
3=Neutral
2=Agree
1=Strongly agree
9=Don't know

Create a random number and display the questions according to that number. For analysis you get always the same codes.

2. Tayloring:
Create a random number. (rn)
create your answer options like:
1 = {if(rn==1,"Strongly agree","Strongly disagree")}
2 = {if(rn==1,"Agree","Disagree")}
...
9=Don't know

In this case you have only one question, but you have to recode the codes for analysis.
E.g. "if (rn=2) and (code<>9) then code=6-code"

You can do this either in your analysis software, EXCEL, OpenOffice, SPSS, or whatever.
But you can do it in LS by Expression Manager, too.

sample attached


Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 7 months ago by Joffm.
The following user(s) said Thank You: wendyt
The topic has been locked.
  • wendyt
  • wendyt's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago #157564 by wendyt
Replied by wendyt on topic Randomize two sets of answer choices
Thank you very much Joffm. The first way is easy to manage ;)
Cheers!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #157566 by tpartner
Replied by tpartner on topic Randomize two sets of answer choices
Here is a JavaScript solution to randomly invert all except the last answer within a single question.

Set up your survey to use JavaScript and place the following script in the source of the question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Generate random number between 1 &amp; 2
    var rand = Math.floor(Math.random() * 2) + 1
 
    // If the random number = 2...
    if(rand == 2) {
      // Reverse the answer order (excepting the last answer)
      var lastAnswer = $('.answer-item:last', thisQuestion);
      var tr = $('.answer-item', thisQuestion).not(lastAnswer).detach().toArray();
      tr.reverse();
      $.each(tr, function(i, el) {
        $('.answers-list', thisQuestion).append(el);
      });
      $('.answers-list', thisQuestion).append(lastAnswer);
    }
  });  
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...8-14.lss
File Size:15 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: wendyt
The topic has been locked.
  • wendyt
  • wendyt's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago #157717 by wendyt
Replied by wendyt on topic Randomize two sets of answer choices
Thanks so much! i'm new to JavaScript solution but would definitely try this out.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose