- Posts: 11
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Use of Expression Manager to allow values for unchecked boxes.
- gaartsen
- Topic Author
- Offline
- New Member
Less
More
4 years 5 months ago #190804
by gaartsen
Use of Expression Manager to allow values for unchecked boxes. was created by gaartsen
Hi,
I have a situation where the I have 4 options that can either be true or false.
I want to use multiple choice for the 4 answers, and add a value to "non" selected boxes in those cases where the option is false.
I tried to do that using this EM statement in the Relevance Equation of the main question.
FYI, Answers 2 and 4 are true.
{sum(if(G5Q00001_SQ001 == "Y", -1, 1), if(G5Q00001_SQ002 == "Y", 1, -1), if(G5Q00001_SQ003 == "Y", -1, 1), if(G5Q00001_SQ004 == "Y", 1, -1))}
I have tried with this as well:
{sum(if(G5Q00001_SQ001 == "1", -1, 1), if(G5Q00001_SQ002 == "1", 1, -1), if(G5Q00001_SQ003 == "1", -1, 1), if(G5Q00001_SQ004 == "1", 1, -1))}
I wanted to use this method so I can use nagative values when scoring all questions in the group.
This seemed to me a quite straight forward method, but when I do a Logic Check I see this
I am not quite sure what I do wrong, but it's clear something is not quite right.
Can anyone please shed a light on this?
Many thanks in advance.
I have a situation where the I have 4 options that can either be true or false.
I want to use multiple choice for the 4 answers, and add a value to "non" selected boxes in those cases where the option is false.
I tried to do that using this EM statement in the Relevance Equation of the main question.
FYI, Answers 2 and 4 are true.
{sum(if(G5Q00001_SQ001 == "Y", -1, 1), if(G5Q00001_SQ002 == "Y", 1, -1), if(G5Q00001_SQ003 == "Y", -1, 1), if(G5Q00001_SQ004 == "Y", 1, -1))}
I have tried with this as well:
{sum(if(G5Q00001_SQ001 == "1", -1, 1), if(G5Q00001_SQ002 == "1", 1, -1), if(G5Q00001_SQ003 == "1", -1, 1), if(G5Q00001_SQ004 == "1", 1, -1))}
I wanted to use this method so I can use nagative values when scoring all questions in the group.
This seemed to me a quite straight forward method, but when I do a Logic Check I see this
I am not quite sure what I do wrong, but it's clear something is not quite right.
Can anyone please shed a light on this?
Many thanks in advance.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11637
- Thank you received: 2737
4 years 5 months ago #190806
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Use of Expression Manager to allow values for unchecked boxes.
Can you attach a LSS file with just the relevant questions, so that we can have a look at it? I don't see an error immediately, at least not in the screenshot, in the text itself the =='1' is obviously wrong, but I in the screenshot it is correct.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: gaartsen
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
4 years 5 months ago - 4 years 5 months ago #190807
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Use of Expression Manager to allow values for unchecked boxes.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 5 months ago by Joffm.
The following user(s) said Thank You: gaartsen
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11637
- Thank you received: 2737
4 years 5 months ago #190809
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Use of Expression Manager to allow values for unchecked boxes.
Looking at Joffm's screenshot and your's I see that LS is marking the first { as red. So your problem seems to be there and it looks like you have space between the { and the sum.
Take out the space there and at the end as well and see what happens.
Take out the space there and at the end as well and see what happens.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: gaartsen
The topic has been locked.
- gaartsen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
4 years 5 months ago #190812
by gaartsen
Replied by gaartsen on topic Use of Expression Manager to allow values for unchecked boxes.
I noticed that too, but upon checking the actual statement, there are no spaces at all.
The LS even adds space between the "-" and the "1".
The LS even adds space between the "-" and the "1".
The topic has been locked.
- gaartsen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
4 years 5 months ago #190814
by gaartsen
Replied by gaartsen on topic Use of Expression Manager to allow values for unchecked boxes.
Thanks for the very quick replies everyone
I'm using Version 2.72.3+171020, as there seem to be a lot of changes going to Version 3.
Looking at your statement, I saw the missing curly brackets. I removed the curly brackets, and that seems to work OK. Will have to test the scoring though.
I'm using Version 2.72.3+171020, as there seem to be a lot of changes going to Version 3.
Looking at your statement, I saw the missing curly brackets. I removed the curly brackets, and that seems to work OK. Will have to test the scoring though.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11637
- Thank you received: 2737
4 years 5 months ago #190818
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Use of Expression Manager to allow values for unchecked boxes.
Did you put this equation into the validation field of the question???
Because I thought you uses an equation question for this sum.
In the validation fields and the relevance equation you are not supposed to use curly brackets. I find it a little confusing, that in some places you need the curly brackets and in others you shouldn't use them. I would have made it a common rule, any equation needs to be wrapped with {} it is not that much of extra coding and it would be a clear rule.
I think the theory behind it is that in the validation and the relevance equation you can only include expression manager code and nothing else, so yes, in theory the system doesn't need the curly brackets, but I still find it confusing and not consistent.
Because I thought you uses an equation question for this sum.
In the validation fields and the relevance equation you are not supposed to use curly brackets. I find it a little confusing, that in some places you need the curly brackets and in others you shouldn't use them. I would have made it a common rule, any equation needs to be wrapped with {} it is not that much of extra coding and it would be a clear rule.
I think the theory behind it is that in the validation and the relevance equation you can only include expression manager code and nothing else, so yes, in theory the system doesn't need the curly brackets, but I still find it confusing and not consistent.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: gaartsen
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
4 years 5 months ago #190823
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Use of Expression Manager to allow values for unchecked boxes.
Oh, yes,
therefore my logic check looked very different.
And I thought he displays the sum below the question text or somewhere else later.
And again a reason always to send the lss export.
Joffm
therefore my logic check looked very different.
And I thought he displays the sum below the question text or somewhere else later.
And again a reason always to send the lss export.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- gaartsen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
4 years 5 months ago #190829
by gaartsen
Replied by gaartsen on topic Use of Expression Manager to allow values for unchecked boxes.
It's working OK. I really appreciate all your help.
irt. The LSS, would a .lsq have helped? If not, what does constitute "relevant sections"?
irt. The LSS, would a .lsq have helped? If not, what does constitute "relevant sections"?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11637
- Thank you received: 2737
4 years 5 months ago #190830
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Use of Expression Manager to allow values for unchecked boxes.
LSQ doesn't really help for a couple of reasons:
1. It is only a question that needs to be imported into a survey. So we don't have the original settings and those could impact the behavior.
2. It is extra work for the helpers in the forum to create a new survey and a question group to later import your .LSQ. also, the language must be the same one as in the LSQ, which is extra work to find out. With the .LSS we just need to import a file and can start trouble shooting.
So it is always recommended to provide a LSS. Help us to help you.
It is a little bit more work for you, but at the end it is you asking for help, so this little extra work should be OK.
Also, you shouldn't just send the whole survey, because this also makes it difficult for us to see where the problem is. And you probably don't want to post your whole survey on the internet anyway. So best thing is to create a copy of your survey, delete all questions that have nothing to do with the problem and then export it as a LSS file.
1. It is only a question that needs to be imported into a survey. So we don't have the original settings and those could impact the behavior.
2. It is extra work for the helpers in the forum to create a new survey and a question group to later import your .LSQ. also, the language must be the same one as in the LSQ, which is extra work to find out. With the .LSS we just need to import a file and can start trouble shooting.
So it is always recommended to provide a LSS. Help us to help you.
It is a little bit more work for you, but at the end it is you asking for help, so this little extra work should be OK.
Also, you shouldn't just send the whole survey, because this also makes it difficult for us to see where the problem is. And you probably don't want to post your whole survey on the internet anyway. So best thing is to create a copy of your survey, delete all questions that have nothing to do with the problem and then export it as a LSS file.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: gaartsen
The topic has been locked.
- gaartsen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
4 years 5 months ago #190831
by gaartsen
Replied by gaartsen on topic Use of Expression Manager to allow values for unchecked boxes.
All makes perfectly sense. I will do so when the next question pops up.
Many thanks for all your help so far.
Many thanks for all your help so far.
The topic has been locked.