- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Relevance conditions not working for group
- jcpsarsi
- Topic Author
- Offline
- New Member
Less
More
3 years 6 months ago #205424
by jcpsarsi
Relevance conditions not working for group was created by jcpsarsi
Dear all,
The attached survey has four groups: 1) job, 2) setting, 3) location, and 4) equation. For the location group, it is supposed to appear if either of the following two conditions is met:
1. Secretary is selected for the job question and "Yes" is selected for the triggered setting group question (set01 == "A2")
2. Either "Coach" or "Teacher" is selected for the job question (regexMatch("/Teacher|Coach/",job01.shown)). In this case, the setting group will be skipped.
As can be seen in the last equation question, with either of the above conditions met, set01=="A2" or regexMatch("/Teacher|Coach/",job01.shown) equals 1. However, the survey only works as intended when the first condition is met, but not the second condition.
Thanks for help!
Bo
The attached survey has four groups: 1) job, 2) setting, 3) location, and 4) equation. For the location group, it is supposed to appear if either of the following two conditions is met:
1. Secretary is selected for the job question and "Yes" is selected for the triggered setting group question (set01 == "A2")
2. Either "Coach" or "Teacher" is selected for the job question (regexMatch("/Teacher|Coach/",job01.shown)). In this case, the setting group will be skipped.
As can be seen in the last equation question, with either of the above conditions met, set01=="A2" or regexMatch("/Teacher|Coach/",job01.shown) equals 1. However, the survey only works as intended when the first condition is met, but not the second condition.
Thanks for help!
Bo
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12779
- Thank you received: 3940
3 years 6 months ago #205425
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Relevance conditions not working for group
Hi,
because of your filter on "set01" this question is not asked if "Coach" or "Teacher" was selected in "job01".
Therefore the value for "set01" is not defined and the relevance equation will fail.
In these cases you have to use NAOK.
But in my opinion the regex is not necessary.
Just enter
set01.NAOK=="A2" OR job01=="A2" OR job01=="A3"
Joffm
because of your filter on "set01" this question is not asked if "Coach" or "Teacher" was selected in "job01".
Therefore the value for "set01" is not defined and the relevance equation will fail.
In these cases you have to use NAOK.
But in my opinion the regex is not necessary.
Just enter
set01.NAOK=="A2" OR job01=="A2" OR job01=="A3"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: jcpsarsi
The topic has been locked.
- jcpsarsi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
3 years 6 months ago #205426
by jcpsarsi
Replied by jcpsarsi on topic Relevance conditions not working for group
That is why! I updated the code and it worked beautifully. The reason to use regex is because the full drop down list is much longer and contain multiple teacher (e.g., intervention teacher, resource teacher, classroom teacher, etc.) and coach entries.
Thanks so much!
Thanks so much!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
3 years 6 months ago #205455
by DenisChenu
For exemple here
IT01
IT02
RT01
RT02
CT01
…
And you can use «substr(job01,0,2) == "IT" or substr(job01,0,2) == "RT"» for example
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 Relevance conditions not working for group
In this case : i use different string in code,jcpsarsi wrote: That is why! I updated the code and it worked beautifully. The reason to use regex is because the full drop down list is much longer and contain multiple teacher (e.g., intervention teacher, resource teacher, classroom teacher, etc.) and coach entries.
Thanks so much!
For exemple here
IT01
IT02
RT01
RT02
CT01
…
And you can use «substr(job01,0,2) == "IT" or substr(job01,0,2) == "RT"» for example
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.
- jcpsarsi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
3 years 6 months ago #205479
by jcpsarsi
Replied by jcpsarsi on topic Relevance conditions not working for group
That is a smart strategy. Thanks for sharing!
The topic has been locked.