- Posts: 10
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Make none mandatory comment mandatory based on likert scale selection
- kohuke
- Topic Author
- Offline
- New Member
Less
More
4 years 9 months ago - 4 years 9 months ago #186166
by kohuke
Make none mandatory comment mandatory based on likert scale selection was created by kohuke
I might sound dumb, but how do I achieve the following result:
A question group contains 2 questions - one of them is likert scale and other is a comment field. How can I make comment field mandatory if the participant has selected even one answer option which is highlighted with yellow on screenshot?
Right now the comment question is not mandatory. I tried to follow the instructions here: www.limesurvey.org/es/foro/can-i-do-this...put-if-answer-equals , but when I tried to have the "==" either the lable of the answer option or the code of the answer option the question didn't go mandatory.
I am also reading the manual: manual.limesurvey.org/Expression_Manager#Access_to_Variables , but again I am not really understanding how can I make what I need happen :(
That much I know that I can make the comment show or be hidden if a certain answer option is selected, however I do want the comment field always be present so I don't think I can achieve it with conditions.
A question group contains 2 questions - one of them is likert scale and other is a comment field. How can I make comment field mandatory if the participant has selected even one answer option which is highlighted with yellow on screenshot?
Right now the comment question is not mandatory. I tried to follow the instructions here: www.limesurvey.org/es/foro/can-i-do-this...put-if-answer-equals , but when I tried to have the "==" either the lable of the answer option or the code of the answer option the question didn't go mandatory.
I am also reading the manual: manual.limesurvey.org/Expression_Manager#Access_to_Variables , but again I am not really understanding how can I make what I need happen :(
That much I know that I can make the comment show or be hidden if a certain answer option is selected, however I do want the comment field always be present so I don't think I can achieve it with conditions.
Last edit: 4 years 9 months ago by kohuke.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
4 years 9 months ago #186180
by jelo
You can make the comment field mandatory via the Logic section in the advanced settings of the text/comment field.
A bit ExpressionScript (ExpressionManager) knowhow is needed. You already pointed to a thread where that is shown.
Please create a survey (LSS export) with your the two questions and attach that here. And what LimeSurvey version is used?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Make none mandatory comment mandatory based on likert scale selection
kohuke wrote: That much I know that I can make the comment show or be hidden if a certain answer option is selected, however I do want the comment field always be present so I don't think I can achieve it with conditions.
You can make the comment field mandatory via the Logic section in the advanced settings of the text/comment field.
A bit ExpressionScript (ExpressionManager) knowhow is needed. You already pointed to a thread where that is shown.
Please create a survey (LSS export) with your the two questions and attach that here. And what LimeSurvey version 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.
- kohuke
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 years 9 months ago #186185
by kohuke
Replied by kohuke on topic Make none mandatory comment mandatory based on likert scale selection
I did an export of one of the survey groups (I have more with the same option needed). Hopefully this is enough.
Version 3.17.3+190429 should be the version.
Sadly this is the first time I am asked to have that kind of check in place and hopefully someone can dumb it down so I can do what is asked.
Version 3.17.3+190429 should be the version.
Sadly this is the first time I am asked to have that kind of check in place and hopefully someone can dumb it down so I can do what is asked.
Attachments:
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
4 years 9 months ago #186192
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 Make none mandatory comment mandatory based on likert scale selection
Always export LSS (complete example). If you export a LSQ, other will need to create a new survey, check for the correct language to be able to import the LSQ and it still differ from your survey.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- kohuke
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 years 9 months ago #186194
by kohuke
Replied by kohuke on topic Make none mandatory comment mandatory based on likert scale selection
Thank you for the explanation and sorry. Here's the full survey.
The topic has been locked.
- kohuke
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 years 9 months ago #186254
by kohuke
Replied by kohuke on topic Make none mandatory comment mandatory based on likert scale selection
I have been experimenting with some strings:
where K2Kom = comment question itself, K2_SK2Q001 = question and "Ei ole nõus" = answer option. But when I select just the 1st answer to have the "ei ole nõus" option and rest with something else it still jumps to next question when everything else is selected.
When I tried to add all of the subquestion to make comment mandatory if the answer option is shown I get told that invalid code
Can anyone assist? Cause I am really lost
Code:
K2Kom.mandatory=if(K2_SK2Q001 == "Ei ole nõus", "")
When I tried to add all of the subquestion to make comment mandatory if the answer option is shown I get told that invalid code
Code:
K2Kom.mandatory=if((K2_SK2Q001 == "Ei ole nõus", "") OR (K2_SK2Q002 == "Ei ole nõus", "") OR (K2_SK2Q003 == "Ei ole nõus", "") OR (K2_SK2Q004 == "Ei ole nõus", "") OR (K2_SK2Q005 == "Ei ole nõus", "") OR (K2_SK2Q006 == "Ei ole nõus", ""))
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
4 years 9 months ago - 4 years 9 months ago #186267
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 Make none mandatory comment mandatory based on likert scale selection
When providing sample surveys, please only include the relevant questions. The volunteers giving help here do not have time to go threw a bunch of survey questions only to find that they have nothing to do with the problem.
Expression Manager uses question/sub-question/answer codes, not the labels.
You can test whether any row in the array is answered with one of the first two items with an equation like this:
This effectively says return a sum of all of the K2 sub-questions having an answer equaling "K2K01" or "K2K02".
Please refer to the Expression Manager documentation for available functions - manual.limesurvey.org/Expression_Manager#Access_to_Functions
So, the Question validation equation for the comment question could be like this (line-breaks inserted for clarity):
And, the Question validation tip could be like this (line-breaks inserted for clarity):
Sample survey attached:
Expression Manager uses question/sub-question/answer codes, not the labels.
You can test whether any row in the array is answered with one of the first two items with an equation like this:
Code:
sum(countifop("==", 'K2K01', that.K2), countifop("==", 'K2K02', that.K2)) > 0
This effectively says return a sum of all of the K2 sub-questions having an answer equaling "K2K01" or "K2K02".
Please refer to the Expression Manager documentation for available functions - manual.limesurvey.org/Expression_Manager#Access_to_Functions
So, the Question validation equation for the comment question could be like this (line-breaks inserted for clarity):
Code:
(sum(countifop("==", 'K2K01', that.K2), countifop("==", 'K2K02', that.K2)) > 0 AND !is_empty(K2Kom)) OR sum(countifop("==", 'K2K01', that.K2), countifop("==", 'K2K02', that.K2)) == 0
And, the Question validation tip could be like this (line-breaks inserted for clarity):
Code:
{ if( (sum(countifop("==", 'K2K01', that.K2), countifop("==", 'K2K02', that.K2)) > 0 AND !is_empty(K2Kom)) OR sum(countifop("==", 'K2K01', that.K2), countifop("==", 'K2K02', that.K2)) == 0, 'Valid', 'Invalid!' ) }
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 9 months ago by tpartner.
The topic has been locked.
- kohuke
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 years 9 months ago #186272
by kohuke
Replied by kohuke on topic Make none mandatory comment mandatory based on likert scale selection
Thank you very much for the assistance and the explanations. I didn't think that those things should be placed under "Logic" section, furthermore to use a "mathematical" function.
I got to modify all of my question I needed as well as gotten a decent idea on how to accommodate this function to other things if needed.
I got to modify all of my question I needed as well as gotten a decent idea on how to accommodate this function to other things if needed.
The topic has been locked.