- Posts: 162
- Thank you received: 14
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Dynamically show answer options for ranking based on previous question
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
7 years 5 months ago #143877
by teracomp
Dave Phillips
Dynamically show answer options for ranking based on previous question was created by teracomp
I have an Array question with a Likert5 scale from Extreme Need to No Need. There are 20 options for the respondent to indicate the level of need. After they mark the level of need, the following question asks them to Rank Order those marked as Extreme Need.
Q1. What do you feel are the most pressing needs in the world today? (Array with 20 "needs" to mark)
Answers:
5 - Extreme need
4 - Strong need
3 - Moderate need
2 - Slight need
0 - No need
Q2. Please rank order those identified as Extreme Need (Rank answers based on Q1)
Is it possible to dynamically create a list of answer options for ranking in Q2 based on all items marked as Extreme need?
Q1. What do you feel are the most pressing needs in the world today? (Array with 20 "needs" to mark)
Answers:
5 - Extreme need
4 - Strong need
3 - Moderate need
2 - Slight need
0 - No need
Q2. Please rank order those identified as Extreme Need (Rank answers based on Q1)
Is it possible to dynamically create a list of answer options for ranking in Q2 based on all items marked as Extreme need?
Dave Phillips
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
7 years 5 months ago #143885
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Dynamically show answer options for ranking based on previous question
Hi, teracomp,
short answer:
LS has no support for dynamic lists. That's sad, if you are used to dynamic lists (in commercial products).
Jelo mentioned this several times in the last months.
Now you are challenged to leave the preconceived path and find another solution.
Like:
You display the "extreme need" answers in a "multi-numeric" with sliders.
You know how to do this from a former question. https:/https://www.limesurvey.org/de/foren/can-i-do-this-with-limesurvey/107494-allocate-weighting-across-subquestions-ranking-with-percentage
And you know how to change the gap between the items.
This way you get the same (and more) information about the ranking - and the real need - of your "extreme need" items.
(screenshots)
A1Q1 is the code of the scale question.
Best regards
Joffm
short answer:
LS has no support for dynamic lists. That's sad, if you are used to dynamic lists (in commercial products).
Jelo mentioned this several times in the last months.
LimeSurvey is lacking a way to build dynamic lists which can be used to solve your issue.
You can vote for this feature here:
bugs.limesurvey.org/view.php?id=11688
Now you are challenged to leave the preconceived path and find another solution.
Like:
You display the "extreme need" answers in a "multi-numeric" with sliders.
You know how to do this from a former question. https:/https://www.limesurvey.org/de/foren/can-i-do-this-with-limesurvey/107494-allocate-weighting-across-subquestions-ranking-with-percentage
And you know how to change the gap between the items.
This way you get the same (and more) information about the ranking - and the real need - of your "extreme need" items.
(screenshots)
A1Q1 is the code of the scale question.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: teracomp
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 17
7 years 5 months ago - 7 years 5 months ago #143886
by urbana
Replied by urbana on topic Dynamically show answer options for ranking based on previous question
Or you can solve it with javascript.
Put that in the question where they can order the needs:
What do you have to do?
1. First you make your questions with the needs and the scale from 1 to 5
2. Then add the question to order items with all needs
3. Adapt the script above
The script goes through all needs and check for the extrem answer. If it is not extreme then the list item is not shown and can't be ranked
Put that in the question where they can order the needs:
Code:
$(document).ready(function(){ var n1 = "{INSERTANS:342642X204X6242N1}"; //put here all the codes of the need questions var n2 = "{INSERTANS:342642X204X6242N2}"; var n3 = "{INSERTANS:342642X204X6242N3}"; var n4 = "{INSERTANS:342642X204X6242N4}"; var n5 = "{INSERTANS:342642X204X6242N5}"; var n6 = "{INSERTANS:342642X204X6242N6}"; if(n1 != "5 - Extreme need") { // 5 - Extreme need = is the answer text from before //it is not extreme need so we don't show it $("#javatbd342642X204X6243N1").css("display","none"); } if(n2 != "5 - Extreme need") { $("#javatbd342642X204X6243N2").css("display","none"); } if(n3 != "5 - Extreme need") { $("#javatbd342642X204X6243N3").css("display","none"); } if(n4 != "5 - Extreme need") { $("#javatbd342642X204X6243N4").css("display","none"); } if(n5 != "5 - Extreme need") { $("#javatbd342642X204X6243N5").css("display","none"); } if(n6 != "5 - Extreme need") { $("#javatbd342642X204X6243N6").css("display","none"); } });
What do you have to do?
1. First you make your questions with the needs and the scale from 1 to 5
2. Then add the question to order items with all needs
3. Adapt the script above
The script goes through all needs and check for the extrem answer. If it is not extreme then the list item is not shown and can't be ranked
Last edit: 7 years 5 months ago by urbana.
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 17
7 years 5 months ago #143887
by urbana
Replied by urbana on topic Dynamically show answer options for ranking based on previous question
Here is a sample survey with this js code
Attachments:
The following user(s) said Thank You: teracomp
The topic has been locked.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
7 years 5 months ago #143904
by teracomp
Dave Phillips
Replied by teracomp on topic Dynamically show answer options for ranking based on previous question
Thanks Urbana! Greatly appreciate the sample and code. I was pretty sure jQuery would have to come to the rescue after seeing JoffM's response. With your code, I have a running start on the solution.
Dave Phillips
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 17
7 years 5 months ago #143905
by urbana
Replied by urbana on topic Dynamically show answer options for ranking based on previous question
Great that it worked! You'r welcome
The topic has been locked.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
7 years 5 months ago #143922
by teracomp
Dave Phillips
Replied by teracomp on topic Dynamically show answer options for ranking based on previous question
It almost worked. The problem I have is this is a mandatory question (the ranking). So...if there are hidden elements, the interface doesn't know about it, so it won't let me advance to the next question.
I'm not sure what property has to get reset.
I'm not sure what property has to get reset.
Dave Phillips
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 17
7 years 5 months ago #143923
by urbana
Replied by urbana on topic Dynamically show answer options for ranking based on previous question
You could take a look in the console and check how the li Items are marked when draggging them to the right. And then then marke the hidden Elements as well.
Or you could try to change the Script and instead of hidding them you could detach them.
I don't know wether that works but perhaps there is just a Script that Checks if every Element is moved so when you detach them it could work.
Play a little bit around I am sure you could trick the system
Or you could try to change the Script and instead of hidding them you could detach them.
I don't know wether that works but perhaps there is just a Script that Checks if every Element is moved so when you detach them it could work.
Play a little bit around I am sure you could trick the system
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
7 years 5 months ago #143931
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Dynamically show answer options for ranking based on previous question
Hi, teracomp,
let me say something about your approach.
First two obvious things:
1. Of course you do the ranking only if two or more items were rated "5". At the end some ways of the relevance equation.
2. If only one item was rated "5", you should set the rank value of this item to "1",. Normally it fulfills the ranking criteria, but because of obvious reasons the ranking isn't done by the respondents.
Well, it's very clear and easy to follow by the respondents.
BUT: Did you think about the analysis?
Of course, I do not know the incidence of the "5"
Anyway, each of your items will have a different base in the ranking question.
If you calculate a mean of the rankings, what does it say?
Example:
Item 5 was rated "5" only twice, but each time ranked 1st. So the mean of this item is 1.00
Item 8 was rated "5" twenty times and the mean is 1.75
So, how will you compare?
A workaround is to distribute "dummy" ranks to all not ranked items, e.g. the mean value of all not used ranks, or maybe with consideration of the rating in the question before, some "weighted dummy ranks".
And last but not least four ways of a relevance setting to count the "5" ratings:
A1Q1 is the question code. And example with only 5 subquestions.
1. The longest, but easiest to understand:
{sum(if(A1Q1_SQ001==5,1,0),if(A1Q1_SQ002==5,1,0),if(A1Q1_SQ003==5,1,0),if(A1Q1_SQ004==5,1,0),if(A1Q1_SQ005==5,1,0))}
You sum up:
If the 1st subquestion is equal 5, you sum 1, else 0
If the 2nd subquestion is equal 5, you sum 1, else 0
...
2. The use of boolean expression
{sum(A1Q1_SQ001==5,A1Q1_SQ002==5,A1Q1_SQ003==5,A1Q1_SQ004==5,A1Q1_SQ005==5)}
Again you sum up.
And you know that a boolean comparison is equal 1, if true, 0, if false.
So again you sum up the five subquestion with each comparison has a value of 1 or 0.
3. Use of the function countifop (Count the number of answered questions in the list which pass the criteria (arg op value))
{countifop('==',5,A1Q1_SQ001,A1Q1_SQ002,A1Q1_SQ003,A1Q1_SQ004,A1Q1_SQ005)}
You see the first two parameters, which say "equal" and "5".
Then the five subquestions.
4. Use of countifop and "that"
{countifop('==',5,that.A1Q1.NAOK)}
You count the appearance of "=5" in the whole question A1Q1.
(The 'that' variable is like the 'self' variable, but lets you refer to other questions.)
manual.limesurvey.org/Expression_Manager....27that.27_variables
Beause I set the relevance in the next question I refer to the "other" question A1Q1
How to solve your current problem with the hidden rank items, I have not the least idea.
To be honest, my knowledge of JS is very limited. (very, very, very limited)
Best regards
Joffm
let me say something about your approach.
First two obvious things:
1. Of course you do the ranking only if two or more items were rated "5". At the end some ways of the relevance equation.
2. If only one item was rated "5", you should set the rank value of this item to "1",. Normally it fulfills the ranking criteria, but because of obvious reasons the ranking isn't done by the respondents.
Well, it's very clear and easy to follow by the respondents.
BUT: Did you think about the analysis?
Of course, I do not know the incidence of the "5"
Anyway, each of your items will have a different base in the ranking question.
If you calculate a mean of the rankings, what does it say?
Example:
Item 5 was rated "5" only twice, but each time ranked 1st. So the mean of this item is 1.00
Item 8 was rated "5" twenty times and the mean is 1.75
So, how will you compare?
A workaround is to distribute "dummy" ranks to all not ranked items, e.g. the mean value of all not used ranks, or maybe with consideration of the rating in the question before, some "weighted dummy ranks".
And last but not least four ways of a relevance setting to count the "5" ratings:
A1Q1 is the question code. And example with only 5 subquestions.
1. The longest, but easiest to understand:
{sum(if(A1Q1_SQ001==5,1,0),if(A1Q1_SQ002==5,1,0),if(A1Q1_SQ003==5,1,0),if(A1Q1_SQ004==5,1,0),if(A1Q1_SQ005==5,1,0))}
You sum up:
If the 1st subquestion is equal 5, you sum 1, else 0
If the 2nd subquestion is equal 5, you sum 1, else 0
...
2. The use of boolean expression
{sum(A1Q1_SQ001==5,A1Q1_SQ002==5,A1Q1_SQ003==5,A1Q1_SQ004==5,A1Q1_SQ005==5)}
Again you sum up.
And you know that a boolean comparison is equal 1, if true, 0, if false.
So again you sum up the five subquestion with each comparison has a value of 1 or 0.
3. Use of the function countifop (Count the number of answered questions in the list which pass the criteria (arg op value))
{countifop('==',5,A1Q1_SQ001,A1Q1_SQ002,A1Q1_SQ003,A1Q1_SQ004,A1Q1_SQ005)}
You see the first two parameters, which say "equal" and "5".
Then the five subquestions.
4. Use of countifop and "that"
{countifop('==',5,that.A1Q1.NAOK)}
You count the appearance of "=5" in the whole question A1Q1.
(The 'that' variable is like the 'self' variable, but lets you refer to other questions.)
manual.limesurvey.org/Expression_Manager....27that.27_variables
Beause I set the relevance in the next question I refer to the "other" question A1Q1
How to solve your current problem with the hidden rank items, I have not the least idea.
To be honest, my knowledge of JS is very limited. (very, very, very limited)
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: teracomp
The topic has been locked.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
7 years 5 months ago #143942
by teracomp
Dave Phillips
Replied by teracomp on topic Dynamically show answer options for ranking based on previous question
Thanks Joffm for your insight, most notably, "how will you compare?" I'm with you there! This instrument is in its alpha version and I'm struggling with interpretation of the results, especially with this particular question. I hope we'll get some refinement this week as the survey is viewed by the stakeholders for the effort.
Your points 1..4 are teaching more and more about LimeSurvey. I'll have to stop and consider each of these carefully. I'm getting more familiar with the syntax and I'm quite happy to apply jQuery solutions if the interface doesn't solve the issue. However, I'd rather resort to javascript solutions as the last approach, so I need to learn more about countifop() and your particular use of boolean operations. Much to learn on my end!
Thanks for the response!
Your points 1..4 are teaching more and more about LimeSurvey. I'll have to stop and consider each of these carefully. I'm getting more familiar with the syntax and I'm quite happy to apply jQuery solutions if the interface doesn't solve the issue. However, I'd rather resort to javascript solutions as the last approach, so I need to learn more about countifop() and your particular use of boolean operations. Much to learn on my end!
Thanks for the response!
Dave Phillips
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
7 years 5 months ago #143961
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 Dynamically show answer options for ranking based on previous question
To work around the "mandatory" problem you should be able to filter the ranking question with a hidden multiple-choice question, using JavaScript to hide the multiple-choice and toggle the checkboxes when the corresponding array rows are "Extreme Need". Here's an example of a script to handle that toggling -
www.limesurvey.org/forum/can-i-do-this-w...er-javascript#137115
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: teracomp
The topic has been locked.