Welcome to the LimeSurvey Community Forum

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

Randomization with fixed positions and strange behaviour of exclusive option

  • Orbit-Reiter
  • Orbit-Reiter's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 7 months ago - 1 year 7 months ago #244019 by Orbit-Reiter
Please help us help you and fill where relevant:
Your LimeSurvey version: Community Edition Version 6.0.4+230427
Own server or LimeSurvey hosting: own
Survey theme/template: fruity
==================
Hello!
I have been using the following script (from here ) to fix positions at the bottom (below "Other"-option) in version 3.
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Define the sub-question codes to be placed last
    var lastItems = ['SQ006', 'SQ007', 'SQ008'];
 
    // Loop through those sub-question codes
    $.each(lastItems, function(i, val) {
      // Move that item to the end of the list
      // Multi-choice question
      if($(thisQuestion).hasClass('multiple-opt')) {
        $('.question-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.question-item[id$=X'+qID+val+']', thisQuestion).parent());
      }
      // Array question
      if($(thisQuestion).hasClass('array-flexible-row')) {
        $('.answers-list[id$=X'+qID+val+']', thisQuestion).appendTo($('table.subquestion-list tbody:last', thisQuestion));
      }
      // List-radio question
      if($(thisQuestion).hasClass('list-radio')) {
        $('.answer-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.answer-item[id$=X'+qID+val+']', thisQuestion).parent());
      }
    });  
  });
</script>

It seems it's not working anymore (at least for multi-opt) but I can't find out what to change.


Moreover, I found very strange behaviour of the option I set as an exclusive option. It always is fixed in a position when randomising (even without any script), but always one above its position in the answer list. So when I set the second option as exclusive, it fixes it to the first position. If I set the last option as exclusive, its fixed in the second to last option. Is this a bug?
Last edit: 1 year 7 months ago by Orbit-Reiter.

Please Log in to join the conversation.

  • Orbit-Reiter
  • Orbit-Reiter's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 7 months ago #244021 by Orbit-Reiter
I realised now that the script still works if it is added in the source code of the question label. If it is added in the Script-Tab (without the <script>-tags), it is not working.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose