Welcome to the LimeSurvey Community Forum

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

Sub questions in the wrong order

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190791 by tpartner
Replied by tpartner on topic Sub questions in the wrong order
@AdaSimion, please file a bug report including your sample survey.

In the meantime, a workaround would be to place this script in the source of every group description. It will reposition the array rows according to the sequential sub-question codes.

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Loop through the questions
    $('.array-flexible-row').each(function(i){
 
      var qID = $(this).attr('id').replace(/question/, '');
      var thisQuestion = $('#question'+qID);
 
      // Loop through the sub-question codes
      var i;
      for (i = 1; i < 5; i++) {
 
        var thisRow = $('tr[id^="javatbd"][id$="X'+qID+'SQ00'+i+'"]');
 
        // Reposition the corresponding array row
        $('table.subquestion-list tbody:eq(0)', thisQuestion).append(thisRow);
 
        // Fix the row class
        $(thisRow).removeClass('ls-even, ls-odd');
        if(i % 2 == 0) {
          $(thisRow).addClass('ls-even ');
        }
        else {
          $(thisRow).addClass('ls-odd ');
        }
      } 
    });
    });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...8571.lss
File Size:690 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: AdaSimion
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose