Welcome to the LimeSurvey Community Forum

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

Fix items in the end for 'Multiple + Comments' question

  • evhenii_access
  • evhenii_access's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
19 hours 20 minutes ago #270455 by evhenii_access
Please help us help you and fill where relevant:
Your LimeSurvey version:   LimeSurvey Cloud Version 6.13.3
Own server or LimeSurvey hosting:   LimeSurvey hosting
Survey theme/template:  Bootswatch

==================For ‘Multiple + Comments’ question with randomized answers, I need to fix positions of 2 answers (Other and None) in the end of the list. I already have 3 variants of script from this forum: #1 and #2 by Tony Partner, #3 source not specified.  All 3 variants work fine for ‘Multiple’-type question, but none works for ‘Multiple + Comments’.    Attached is export of test survey – with all 3 variants used for ‘Multiple + Comments’ and for ‘Multiple’.

File Attachment:

File Name: limesurvey...1239.lss
File Size:78 KB
Please help to adjust the code, so that it works for ‘Multiple + Comments’ question, and so that I can fix positions for two answers (Other and None), not just one (None).   


Below are the variants of script I found and tried:     Variant 1:<script type="text/javascript" data-author="Tony Partner">    $(document).on('ready pjax:scriptcomplete',function(){        // The subquestion codes to fix at the end        var fixedCodes = [ '5'];               // Identify this question        var qID = '{QID}';        var thisQuestion = $('#question'+qID);        var itemsLength = $('.answer-item', thisQuestion).length;    var offset = 1;    if($('.answer-item[id$="X'+qID+'other"]', thisQuestion).length > 0) {      offset = 2;    }         // Move the fixed items        $.each(fixedCodes, function(i, code) {            var thisItem = $('.answer-item[id$="X'+qID+code+'"]', thisQuestion);            var replacedItem = $('.answer-item:eq('+(itemsLength-i-offset)+')', thisQuestion);            $(thisItem).before(replacedItem);            $('.answers-list > ul:last', thisQuestion).append(thisItem);        });    });</script>
 Variant 2:<script type="text/javascript" data-author="Tony Partner">  $(document).on('ready pjax:scriptcomplete',function(){    var fixedItems = ;    //// NO EDITING REQUIRED BELOW HERE ////    // Identify this question    var thisQuestion = $('#question{QID}');    $.each(fixedItems, function(e, code) {      $('li[id$="'+code+'"]').appendTo($('.answers-list', thisQuestion));    });  });</script>



 Variant 3:<script type='text/javascript'>/* Place option at the end of the randomized list */$(document).ready(function() {var move_element="5";/* Please do NOT change the lines below */var move_element="javatbd{SGQ}"+move_element;$("#"+move_element).insertAfter("#question{QID} .answers-list .answer-item:last-child");});</script> 

 

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose