Welcome to the LimeSurvey Community Forum

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

Unwanted Randomization of Answer Options in Array Questions

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197284 by tpartner
In the meantime, you can add this script to the source of an array question to only randomize the sub-questions:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
    var thisTable = $('table.subquestion-list', thisQuestion);
 
    // Randomize the rows
    var rowsArr = [];
    $('tr.answers-list', thisTable).each(function(i){
      $(this).attr('data-index', i);
      rowsArr.push(i);
    });
    shuffleArray(rowsArr);
    $(rowsArr).each(function(i){
      $('tbody:eq(0)', thisTable).append($('tr[data-index="'+this+'"]', thisTable));
    });
 
    // Fix up the row classes
    var rowClass = 1;
    $('tr.answers-list', thisTable).removeClass('ls-even ls-odd').each(function(i) {
      if(i%2 == 0) {
        $(this).addClass('ls-even');
      }
      else {
        $(this).addClass('ls-odd');
      }
    });
    });
 
  function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
      var j = Math.floor(Math.random() * (i + 1));
      var temp = array[i];
      array[i] = array[j];
      array[j] = temp;
    }
    return array;
  }  
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197288 by holch

I think Yves' point is about array questions where you have both sub-questions and answers randomized in 4.x.


Oh, now I get it. I totally understood his post wrong.

And yes, while I think it is a good idea to provide the option to randomize not only the subquestions of array questions, but also the answer options, this obviously should be optional and set individually.

Imagine you have a scale 1-2-3-4-5, it doesn't make sense to randomize that... Would be a lot of fun for the respondents. ;-)

I really need to set up my new VPS to install my own LS4 for testing. I was waiting because I will need to move to a new VPS, so I didn't want to install anything on the old one. More stuff on it, more stuff to move. Maybe I'll get around it this weekend.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
4 years 1 week ago #197328 by YvesRoy
Hi,

thank you for the script, I'll try it next week.

There actually is a bug track, #16032, open at the end of March but still not assigned.

Yves

Yves Roy
Université de Poitiers, France
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 week ago #197359 by holch
And here the link to the bug report, to make it easier to follow it:
bugs.limesurvey.org/view.php?id=16032

I think this is a very urgent matter, because for most work in market research this "feature"/"bug" will make randomization in array questions unusable, if randomization of subquestions will force a randomization in answer options.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose