Welcome to the LimeSurvey Community Forum

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

How to dynamically change the order of items in a ranking question?

  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 months 3 weeks ago #266197 by jelo
The item order of a ranking question should be the same as the order in which four randomized question groups are displayed.
Since the ranking question has no item relevance, there would only be an array filter to manipulate the item list.
Perhaps a hidden multiple-choice question with 16 items to select the items in the correct order and filter the ranking question.

Any other approaches you can think of that are worth exploring?


 

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 3 weeks ago - 4 months 3 weeks ago #266222 by Joffm
Hi,
I found a solution based on the "survey wide randomization" that Tony provided.

After the randomized groups there is an equation (order) 
{list(if(Q1.gseq==1,'A01',if(Q2.gseq==1,'A02',if(Q3.gseq==1,'A03',if(Q4.gseq==1,'A04','')))),if(Q1.gseq==2,'A01',if(Q2.gseq==2,'A02',if(Q3.gseq==2,'A03',if(Q4.gseq==2,'A04','')))),if(Q1.gseq==3,'A01',if(Q2.gseq==3,'A02',if(Q3.gseq==3,'A03',if(Q4.gseq==3,'A04','')))),if(Q1.gseq==4,'A01',if(Q2.gseq==4,'A02',if(Q3.gseq==4,'A03',if(Q4.gseq==4,'A04','')))))}
Might be improved

Now I get in the equation something like this.
 

Now this script in the ranking question fills the options accordingly
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
 
    //Identify this question
    var qID = '{QID}';
    var thisQuestion = $('#question'+qID);
 
    // Retrieve the answer codes from the "order" question
    var answerCodes = '{order}'.split(',');
 
    // Loop through the answer codes
    $.each(answerCodes, function(i, code) {
          xcode=code.trim();
          $('li[id$="X'+qID+xcode+'"]').appendTo($('ul.sortable-choice', thisQuestion));
    });   
  });
</script>

 

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 months 3 weeks ago by Joffm.
The following user(s) said Thank You: jelo

Please Log in to join the conversation.

  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 months 3 weeks ago #266233 by jelo
Thank you, Joffm. That is an very elegant approach.

Let's see if that workaround will survive the next version of LimeSurvey.

Most workarounds on this page are for EOL versions.

www.limesurvey.org/manual/Workarounds:_M...ime_using_Javascript

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose