Welcome to the LimeSurvey Community Forum

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

Fix two answers at last in multiple choice question showed with columns

  • Oterito
  • Oterito's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 2 weeks ago #255810 by Oterito
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.6.54
Own server or LimeSurvey hosting: Limesurvey hosting
Survey theme/template: fruity
==================
Hi! I want fix the last two options in a multiple choice question showed by 4 columns.

This code worked in 1 column, but when i select show in 4 columns it doesn't work anymore. <script type="text/javascript" charset="utf-8">   $(document).ready(function() {   // Identify this question  var qID = {QID};   // Place the "DK" code option at the end of the list  var answer = $( 'input[id$="X'+qID+'97"]');  var answerItem = $(answer).closest('li');  var answersList = $(answer).closest('ul');  $(answersList).append(answerItem);   });
 $(document).ready(function() {   // Identify this question  var qID = {QID};   // Place the "DK" code option at the end of the list  var answer = $( 'input[id$="X'+qID+'99"]');  var answerItem = $(answer).closest('li');  var answersList = $(answer).closest('ul');  $(answersList).append(answerItem);   });</script>
Can anyone help me please? 

Thanks in advance

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #255815 by tpartner
Can you attach a small sample survey (.lss file) containing only the relevant question?

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: Oterito

Please Log in to join the conversation.

  • Oterito
  • Oterito's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 2 weeks ago - 2 months 2 weeks ago #255818 by Oterito
Here I attach it. Thanks! 

File Attachment:

File Name: limesurvey...4761.lss
File Size:36 KB
Last edit: 2 months 2 weeks ago by Oterito.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #255821 by tpartner
Do you want them fixed before or after the "Otros" item?

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: Oterito

Please Log in to join the conversation.

  • Oterito
  • Oterito's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 2 weeks ago #255822 by Oterito
After other option.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago - 2 months 2 weeks ago #255824 by tpartner
This script will, for example, fix the sub-questions "97" and "99" to the end of the last column:
 
Code:
<script type="text/javascript" data-author="Tony Partner">
 
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // The subquestion codes to fix at the end
        var fixedCodes = ['97', '99'];
 
        // 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>

Sample survey attached: 

File Attachment:

File Name: limesurvey...7611.lss
File Size:35 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 2 months 2 weeks ago by tpartner.
The following user(s) said Thank You: Oterito

Please Log in to join the conversation.

  • Oterito
  • Oterito's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 2 weeks ago #255826 by Oterito
It worked perfect. Thank you very much!

Please Log in to join the conversation.

  • Oterito
  • Oterito's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 2 weeks ago - 2 months 2 weeks ago #255905 by Oterito
Hi! tpartner! Its me again. I applied the same code in a second question with array filter by the first and i am having problems with the visualization. The options are not well distributed in columns. I attach an image below and a sample survey with two question.

 

Is there any way to solve this? Can you help me again please? 

Thanks in advance!


 
Last edit: 2 months 2 weeks ago by Oterito.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #255906 by tpartner
That has nothing to do with my script. It is a core question behaviour - it does not visually handle filtering well when using columns.

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: DenisChenu, Oterito

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #255912 by Joffm
As @tpartner,
the problem is in the order
First the subquestions are randomized and displayed in three columns
and THEN some are hidden by the array filter.
Here you see if you set the array filter mode to "deactivate"
 

Now imagine these subquestions are hidden.

If I remember well, I filed a bug report some years ago.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Oterito

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #255933 by tpartner
There is probably a CSS workaround but I'm away from a computer today.

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: DenisChenu

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago - 2 months 2 weeks ago #255961 by DenisChenu

There is probably a CSS workaround but I'm away from a computer today.

 
Maybe check with this solution : github.com/LimeSurvey/LimeSurvey/pull/3038
(i mean : adding a new class and deactivate the core solution)

Else : doing it in HTML before show the question : gitlab.com/SondagesPro/QuestionSettingsType/arrayFilterHtml

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 2 months 2 weeks ago by DenisChenu.
The following user(s) said Thank You: tpartner, Oterito

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose