- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Parsing top 3 variables
- vincentksk
- Topic Author
- Offline
- New Member
Less
More
7 years 2 weeks ago #149397
by vincentksk
Parsing top 3 variables was created by vincentksk
In my end message screen for my survey, I have 10 recommendations (R1, R2,... R10) that are hidden and depend on the answers on the survey, I would display the top 3 recommendations out of the 10. The recommendations are prioritized so if R1 was triggered, it would be display first over all the other recommendations (R1 > R2 > R3 > R4 and so on).
In the survey, which consists of multiple choice questions, if the user answered Q1 with subquestion SQ001, then mark R4 as being triggered, otherwise no recommendation is being triggered.
If the user answered Q2 with subquestion SQ003, then mark R6 as being triggered. This continues until the end of the survey where a number of recommendations have been triggered.
So far, using equation questions and their relevance equations, I have 10 counters for each recommendation (R1counter, R2counter, etc.), that has a value of 1 if it has been triggered, otherwise it would have a 0 value.
However the part where I struggled is knowing how to stop after checking 3 counters that has a value of 1. Even if I use nested if condition:
{
if (
R1 > 0,
show R1 text,
if (
R2 > 0,
show R2 text,
etc.
)
}
If R1 > 0. then I would show R1 text and the entire chain of if statement would stop. Is there a way to introduce a counter variable and update that variable as I go along the nested if statement?
Or would there be a better way to solution this out?
Many thanks for taking time to read my question
In the survey, which consists of multiple choice questions, if the user answered Q1 with subquestion SQ001, then mark R4 as being triggered, otherwise no recommendation is being triggered.
If the user answered Q2 with subquestion SQ003, then mark R6 as being triggered. This continues until the end of the survey where a number of recommendations have been triggered.
So far, using equation questions and their relevance equations, I have 10 counters for each recommendation (R1counter, R2counter, etc.), that has a value of 1 if it has been triggered, otherwise it would have a 0 value.
However the part where I struggled is knowing how to stop after checking 3 counters that has a value of 1. Even if I use nested if condition:
{
if (
R1 > 0,
show R1 text,
if (
R2 > 0,
show R2 text,
etc.
)
}
If R1 > 0. then I would show R1 text and the entire chain of if statement would stop. Is there a way to introduce a counter variable and update that variable as I go along the nested if statement?
Or would there be a better way to solution this out?
Many thanks for taking time to read my question
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 2 weeks ago #149414
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Parsing top 3 variables
LimeSurvey is missing Listbuilding.
bugs.limesurvey.org/view.php?id=11688
What version/build of LimeSurvey is used?
bugs.limesurvey.org/view.php?id=11688
What version/build of LimeSurvey is used?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 2 weeks ago - 7 years 2 weeks ago #149433
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 Parsing top 3 variables
I don't think you can get there with Expression Manager and relevance. I think you'll have to use a JavaScript loop to hide/show the appropriate recommendations.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 2 weeks ago by tpartner.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
7 years 2 weeks ago #149439
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 Parsing top 3 variables
Seems complex , but think we can have some way.
Quickly explain
1st the 10 equation for 'real condition' (hidden)
- Cond1 : {intval(!is_empty(Q3_SQ02.NAOK))}
[...]
- Cond4 : {intval(!is_empty(Q1_SQ001.NAOK)}
[...]
- Cond6 : {intval(!is_empty(Q3_SQ003.NAOK)}
2nd R1,R2 .... : text display question (hidden)
Condition/relevance equation with
R1: Cond1.NAOK>0
R2: Cond2.NAOK>0 and (sum(Cond1.NAOK)<=4)
[...]
R4: Cond4.NAOK>0 and (sum(Cond1.NAOK,Cond2.NAOK,Cond3.NAOK)<=4)
[...]
R6: Cond6.NAOK>0 and (sum(Cond1.NAOK,Cond2.NAOK,Cond3.NAOK,Cond4.NAOK,Cond5.NAOK)<=4)
[...]
And finally your string, for example :
Quickly explain
1st the 10 equation for 'real condition' (hidden)
- Cond1 : {intval(!is_empty(Q3_SQ02.NAOK))}
[...]
- Cond4 : {intval(!is_empty(Q1_SQ001.NAOK)}
[...]
- Cond6 : {intval(!is_empty(Q3_SQ003.NAOK)}
2nd R1,R2 .... : text display question (hidden)
Condition/relevance equation with
R1: Cond1.NAOK>0
R2: Cond2.NAOK>0 and (sum(Cond1.NAOK)<=4)
[...]
R4: Cond4.NAOK>0 and (sum(Cond1.NAOK,Cond2.NAOK,Cond3.NAOK)<=4)
[...]
R6: Cond6.NAOK>0 and (sum(Cond1.NAOK,Cond2.NAOK,Cond3.NAOK,Cond4.NAOK,Cond5.NAOK)<=4)
[...]
And finally your string, for example :
Code:
<ol> if(R1.relevanceStatus,'<li>'+R1.question+'<li>','')} [...] if(R6.relevanceStatus,'<li>'+R6.question+'<li>','')} [...]
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.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 2 weeks ago #149449
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Parsing top 3 variables
These big workarounds are really a pity.
With List commands on EM level it would save lot's of hours on complex workarounds.
Debugging is then hell.
Difficult to communicate to others when they are used to get this done with a few commands.
www.sawtoothsoftware.com/help/lighthouse...l/listfunctions.html
Sort the list of up to ten (1-10)
Then apply LISTMAX (3) to remove seven from the bottom.
You have your list.
With List commands on EM level it would save lot's of hours on complex workarounds.
Debugging is then hell.
Difficult to communicate to others when they are used to get this done with a few commands.
www.sawtoothsoftware.com/help/lighthouse...l/listfunctions.html
Sort the list of up to ten (1-10)
Then apply LISTMAX (3) to remove seven from the bottom.
You have your list.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
7 years 2 weeks ago #149525
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 Parsing top 3 variables
It's not a workaround here ......
It's the way of LimeSurvey .....
It's the way of LimeSurvey .....
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.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 2 weeks ago #149529
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Parsing top 3 variables
In LimeSurvey it's often a WORKOUT. You write plugins and I submit a featurerequests. And one day somebody will tell me LS is survey development framework and everything makes sense.DenisChenu wrote: It's not a workaround here ......It's the way of LimeSurvey .....
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.