- Posts: 11
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Condition based on number of possible answers
- AndrejL
- Topic Author
- Offline
- New Member
Less
More
13 years 2 months ago - 13 years 2 months ago #57544
by AndrejL
Condition based on number of possible answers was created by AndrejL
Hi!
I'm using array filters in my survey and I encounter a little problem.
It's possible that respondent answers survey in such way that he gets to a question that has no displayed answers.
Here is a simple example: test survey
If answer was checked in Q1 it doesn't display in Q2. So if you checked all 5 answer, second question is empty.
Of course in this case I could use filter if Q1<>1 or Q1<>"... but my case can't be solved this way.
Is there any workaround or filter that prevents question from displaying if number of possible answers is less then n.
Thank you,
Andrej
I'm using array filters in my survey and I encounter a little problem.
It's possible that respondent answers survey in such way that he gets to a question that has no displayed answers.
Here is a simple example: test survey
If answer was checked in Q1 it doesn't display in Q2. So if you checked all 5 answer, second question is empty.
Of course in this case I could use filter if Q1<>1 or Q1<>"... but my case can't be solved this way.
Is there any workaround or filter that prevents question from displaying if number of possible answers is less then n.
Thank you,
Andrej
Last edit: 13 years 2 months ago by AndrejL.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10114
- Thank you received: 3595
13 years 2 months ago - 13 years 2 months ago #57545
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Condition based on number of possible answers
It appears that you are using question-by-question mode. Is it possible to separate the questions into different groups and use group-by-group mode? If so, we would be able to use a hidden question to store the number of checked boxes in Q1 and then apply a condition to Q2.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 13 years 2 months ago by tpartner.
The topic has been locked.
- AndrejL
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
13 years 2 months ago #57546
by AndrejL
Replied by AndrejL on topic Condition based on number of possible answers
I can store Q1 and Q2 in different groups but in general survey will be conducted in question-by-question mode.
This problem is just part of a much bigger survey and I can't change display format for hole survey.
This problem is just part of a much bigger survey and I can't change display format for hole survey.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10114
- Thank you received: 3595
13 years 2 months ago #57547
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Condition based on number of possible answers
Well, that makes it considerably more difficult because you can't use a hidden question to tally the number of checked boxes.
I think the only solution would be to use a cookie. I'll need to give it some thought and get back to you.
I think the only solution would be to use a cookie. I'll need to give it some thought and get back to you.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13668
- Thank you received: 2496
13 years 2 months ago #57557
by DenisChenu
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.
Replied by DenisChenu on topic Condition based on number of possible answers
tpartner , what do you think of a javascript in the question to test the number of line visible.
If this number is <1 then click the next button ?
If you don't have time, i can have a look , but only thursday
If this number is <1 then click the next button ?
If you don't have time, i can have a look , but only thursday
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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10114
- Thank you received: 3595
13 years 2 months ago #57562
by tpartner
Gimme a sec.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Condition based on number of possible answers
Duh! Yeah, good idea! I couldn't see the tree because of the forest. :laugh:what do you think of a javascript in the question to test the number of line visible.
If this number is <1 then click the next button ?
Gimme a sec.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10114
- Thank you received: 3595
13 years 2 months ago #57566
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Condition based on number of possible answers
Oh wait...that would make it impossible to go back in the survey.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- AndrejL
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
13 years 2 months ago #57567
by AndrejL
Replied by AndrejL on topic Condition based on number of possible answers
I have to check with higher authority :dry:
But that could be a problem.
If this was not an issue is it doable?
Andrej
But that could be a problem.
If this was not an issue is it doable?
Andrej
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10114
- Thank you received: 3595
13 years 2 months ago - 13 years 2 months ago #57570
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Condition based on number of possible answers
Almost anything is doable We'll just have to revert to my idea of using a cookie.
1) Set up the array filter exclusion between Q1 (the checkbox question) and Q2 (the radio question).
2) Add the following to the end of your template.js file. It is a little script to allow the recovery of cookies.
3) Add the following to the source of Q1. Replace "3" in line 24 with the minimum number of options you would like to display in Q2. The script interrupts the next/submit function, does some math and if less than the minimum number of options are to be shown sets a cookie with a value of 1.
4) Add the following to the source of Q2. The script retrieves the cookie and if the value is 1, unchecks all radio options and moves to the next question.
5) Add the following to the source of Q3 (the next question after the skip). The script retrieves the cookie and if the value is 1, adjusts the "Previous" buttons action to skip over the Q2 and go directly back to Q1.
1) Set up the array filter exclusion between Q1 (the checkbox question) and Q2 (the radio question).
2) Add the following to the end of your template.js file. It is a little script to allow the recovery of cookies.
Code:
// a function to get the value of a cookie by name function getCookie ( cookieName ) { var results = document.cookie.match ( '(^|;) ?' + cookieName + '=([^;]*)(;|$)' ); if ( results ) { return ( unescape ( results[2] ) ); } else { return null; } }
3) Add the following to the source of Q1. Replace "3" in line 24 with the minimum number of options you would like to display in Q2. The script interrupts the next/submit function, does some math and if less than the minimum number of options are to be shown sets a cookie with a value of 1.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { function minShown(minAllowed) { // Interrupt next/submit function $('form#limesurvey').submit(function(){ var visible = $('.multiple-opt input.checkbox').length - $('.multiple-opt input.checkbox:checked').length; // If less than the minimum, clear the question and move on if(visible < minAllowed) { document.cookie = 'lsSkipQ = 1'; } else { document.cookie = 'lsSkipQ = 0'; } // Carry on with submit return true; }); } minShown(3); }); </script>
4) Add the following to the source of Q2. The script retrieves the cookie and if the value is 1, unchecks all radio options and moves to the next question.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Retrieve the cookie var skip = getCookie ('lsSkipQ'); // If we're supposed to skip, uncheck all options and move on if(skip > 0) { $('.list-radio').hide(); $('.list-radio input,radio').attr('checked', false); document.limesurvey.move.value = 'movenext'; document.limesurvey.submit(); } }); </script>
5) Add the following to the source of Q3 (the next question after the skip). The script retrieves the cookie and if the value is 1, adjusts the "Previous" buttons action to skip over the Q2 and go directly back to Q1.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Retrieve the cookie var skip = getCookie ('lsSkipQ'); // Skip previous question if(skip > 0) { $('#moveprevbtn').mousedown(function () { $('#thisstep').val($('#thisstep').val() - 1); }); } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 13 years 2 months ago by tpartner.
The topic has been locked.
- harshagile
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
13 years 1 month ago #58820
by harshagile
Replied by harshagile on topic Condition based on number of possible answers
Hi
Do you have any idea about the limesurvey database.
I have just integrate limesurvey with my database.
But i didn't get table where all the answer stored.
I need to fetch all the response come for perticular survey
So if you have any idea abt that table name then please inform me.
Do you have any idea about the limesurvey database.
I have just integrate limesurvey with my database.
But i didn't get table where all the answer stored.
I need to fetch all the response come for perticular survey
So if you have any idea abt that table name then please inform me.
The topic has been locked.