Welcome to the LimeSurvey Community Forum

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

Partially randomise items in a ranking question

  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 months 2 weeks ago #254205 by paulfiner
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.25.17
Own server or LimeSurvey hosting:Own
Survey theme/template:Fruity
==================
There are lots of workarounds for partially randomising lists for various question types but I couldn't find one for a ranking type question.
Is it possible to fix the last item of a list?

Thanks

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago #254207 by tpartner
Can you attach a small sample survey?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 months 2 weeks ago #254209 by paulfiner
Replied by paulfiner on topic Partially randomise items in a ranking question
Sure, lss file attached

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 months 2 weeks ago - 3 months 2 weeks ago #254220 by tpartner
This script will fix items with answer codes listed in the fixedEndCodes array variable to the end of the choices list.
 
 
Code:
<script type="text/javascript" data-author="Tony Partner">
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // The answer codes of item(s) to be fixed
        var fixedEndCodes = ['9'];
 
        // Identify this question
        var qID = '{QID}';
        var thisQuestion = $('#question'+qID);
 
        // Fix the item(s) to the end
        $.each(fixedEndCodes, function(i, code) {
            if($('ul.sortable-choice li[id$="X'+qID+code+'"]', thisQuestion).length > 0) {
                $('li[id$="X'+qID+code+'"]').appendTo($('ul.sortable-choice', thisQuestion));
            }
        });   
    });
</script>

 Sample survey attached:

File Attachment:

File Name: limesurvey...3472.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 months 2 weeks ago by tpartner.

Please Log in to join the conversation.

  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 months 2 weeks ago #254221 by paulfiner
Replied by paulfiner on topic Partially randomise items in a ranking question
Thanks Tony, I'll have a go at this shortly.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose