Welcome to the LimeSurvey Community Forum

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

Condition doesnot work when controlling group order

  • kzzz_520
  • kzzz_520's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 4 weeks ago #261203 by kzzz_520
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.5.4
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Dear LimeSurvey community,
I have a question regarding survey design. I would like respondents to make 2 group of random order choices. In each group, they first need to choose their preferred housing, and then, select their preferred mode of transportation. It's a combination of a random question and a fixed question. I have learned from Tpartner’s code in other’s topic, which is a JavaScript/CSS solution. It works very effectively for displaying the process of selecting housing and transportation options.

However, I encountered a issue. In each group, I hope the answer to the first question can influence the display of the second question. That is to say, if they choose housing A (new housing) or housing B (new housing), they will be presented with the transportation mode selection question. If they choose housing C (maintain current situation), they will not be presented with the transportation mode selection question.I edited the conditions of the transportation mode selection question to show/hide it. But it malfunctioned. If housing C (current situation) is selected, the transportation mode selection question still appears. I'm confuse how to make it work. Do I need to resolve it through programming? I don't have a programming background and don't know how to proceed.

 Another issue I have is that I don't want to display the 'Previous' button during these two group to prevent them from going back and modifying their previous answers. And in other questions of the survey,  the 'Previous' button is still needed.

I am not sure if there is a way to solve these problem. Maybe you can help me! Please let me know if you need more information. Thank you so much!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 4 weeks ago #261207 by Joffm
Hi,
this approach with "subgroup-1" and "subgroup-2" was something different.
You only have two groups, displayed in randomized order by the randomization group name
and a question that depends on the answer of the previous question.

You only use something like the old "green apple - banana" example with a condition on the next question
And in the second group you just copied the condition. Here it depends on task3.
 

 the transportation mode selection question still appears. I'm confuse how to make it work

I think because your condition didn't contain blanks between the operators.
 

Another issue I have is that I don't want to display the 'Previous' button during these two group to prevent them from going back and modifying their previous answers.

Not really an issue, but a wish.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
  $('#ls-button-previous').hide();
});
</script>

 

File Attachment:

File Name: limesurvey...9733.lss
File Size:67 KB


Joffm

P.S.
I did not see the code for the popover
​​​​​​​Nor did I see where and why you want to use the "hideEmptyColumn" plugin.

 

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

Please Log in to join the conversation.

  • kzzz_520
  • kzzz_520's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 4 weeks ago #261240 by kzzz_520
Thank you Joffm! Thank you very much for your prompt guidance. And I think I've solved my second issue. But for the first one, I want to explain more.
In each group, I use CSS classes 'subgroup-1' and 'subgroup-2' to differentiate the two questions because I want them to appear on different pages. The process I want to achieve is: respondents answer task 1 ---> click 'Next' ---> answer task 2. This way, when respondents see task 2, they cannot go back to modify their answers for task 1. In this way, transportation choices will not affect housing choices.So I want to keep the previous CSS and Java settings. And on this basis, solve the problem of making the condition take effect. 
Also sorry for my problem with my previous condition settings.What you sent is correct. 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 4 weeks ago - 6 months 4 weeks ago #261242 by tpartner
Leave the relevance equation for task2 in place.

Code:
task1_Y001.NAOK=="X001" OR task1_Y001.NAOK=="X002"

Change the "Next" listener in your script:

Code:
        // Listener on the "Next" button
        $('#ls-button-submit').on('click', function(e) {
            if($('.sub-group-1:visible').length > 0) {
                e.preventDefault();
                $('.sub-group-1').hide();
                $('.sub-group-2').show();
                // Remove the line below to keep the "Next" button enabled
                // $('#ls-button-submit').prop('disabled', true);
            }
        });

To this:

Code:
        // Listener on the "Next" button
        $('#ls-button-submit').on('click', function(e) {
            if($('.sub-group-1').is(':visible') &amp;&amp; !$('.sub-group-2').hasClass('ls-irrelevant')) {
                e.preventDefault();
                $('.sub-group-1').hide();
                $('.sub-group-2').show();
            }
        });

Cheers,
Tony Partner

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

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 4 weeks ago - 6 months 4 weeks ago #261243 by tpartner
Stupid, stupid editor!

Replace &amp;&amp; with &&.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 4 weeks ago #261246 by Joffm

Replace &amp;&amp; with &&.


This is a terrible behaviour of this editor

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • kzzz_520
  • kzzz_520's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 3 weeks ago #261698 by kzzz_520
Thank you so so much Tony Partner and Joffm! For your outstanding work and professionalism!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose