- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
URGENT - Question Validation Equation for Total in Text Array
- Clem53
- Topic Author
- Offline
- New Member
Less
More
3 years 5 months ago #207650
by Clem53
URGENT - Question Validation Equation for Total in Text Array was created by Clem53
Hi everyone,
I am developing a survey in which I ask:
- In a first question (Q18a), I ask how many time people spend on a math class
- Then (Q18b) divide the number of minutes in different categories (like presentation of a notion etc.). The question is an array of text with the option "Only numbers" and the total on the columns is presented. The array had 8 sub-questions (from SQ001 to SQ008) and the column for entering the numbers is named "total".
I would like to make it impossible to validate the question if the total is not equal to the response of the last question.
For now, I entered this equation :
(sum(self.SQ001.total.NAOK, self.SQ002.total.NAOK, self.SQ003.total.NAOK, self.SQ004.total.NAOK, self.SQ005.total.NAOK, self.SQ006.total.NAOK, self.SQ007.total.NAOK, self.SQ008.total.NAOK) == (Q18a.shown)) in the Advanced Settings/Question validation equation part.
But it does not work. Could anyone help me ?
I am developing a survey in which I ask:
- In a first question (Q18a), I ask how many time people spend on a math class
- Then (Q18b) divide the number of minutes in different categories (like presentation of a notion etc.). The question is an array of text with the option "Only numbers" and the total on the columns is presented. The array had 8 sub-questions (from SQ001 to SQ008) and the column for entering the numbers is named "total".
I would like to make it impossible to validate the question if the total is not equal to the response of the last question.
For now, I entered this equation :
(sum(self.SQ001.total.NAOK, self.SQ002.total.NAOK, self.SQ003.total.NAOK, self.SQ004.total.NAOK, self.SQ005.total.NAOK, self.SQ006.total.NAOK, self.SQ007.total.NAOK, self.SQ008.total.NAOK) == (Q18a.shown)) in the Advanced Settings/Question validation equation part.
But it does not work. Could anyone help me ?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11661
- Thank you received: 2742
3 years 5 months ago #207654
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 URGENT - Question Validation Equation for Total in Text Array
Just looking at the equation I think it is save to say, that there are errors.
In arrays you acess the different fields (answer options per subquestion) this way:
Questioncode_Subquestioncode_answer code. Not sure if the self can subsitute the question code, but even if it could you would need to have something like self.SQ001_total.
Assuming that the answer code is really "total" and not something else. So this would be the first thing I would change. If this doesn't work, subsitute self with the questioncode and use an underscore.
In arrays you acess the different fields (answer options per subquestion) this way:
Questioncode_Subquestioncode_answer code. Not sure if the self can subsitute the question code, but even if it could you would need to have something like self.SQ001_total.
Assuming that the answer code is really "total" and not something else. So this would be the first thing I would change. If this doesn't work, subsitute self with the questioncode and use an underscore.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11661
- Thank you received: 2742
3 years 5 months ago #207657
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 URGENT - Question Validation Equation for Total in Text Array
And one other thing that looks wrong to me on frist sight:
Q18a.shown
In my opinion this would show the answer option, not the answer given by the respondent. Have a look, just insert {Q18a.shown} in the question text of Q18b and see what happens. I assume that nothing will happen if you use a number question.
If you have a single choice question with the following answer codes and answer options in my opinion it would show the name that you have each answer, not the code.
E.g.
(1) Dog
(2) Cat
Let's assume the respondend chooses (1) Dog {Q18a.shown} should give you "Dog" and {Q18a} should give you "1".
So in your case, I think using {Q18a} without shown should be correct. But best you provide a LSS export with just the relevant questions, because this helps a lot more than guessing around here.
Q18a.shown
In my opinion this would show the answer option, not the answer given by the respondent. Have a look, just insert {Q18a.shown} in the question text of Q18b and see what happens. I assume that nothing will happen if you use a number question.
If you have a single choice question with the following answer codes and answer options in my opinion it would show the name that you have each answer, not the code.
E.g.
(1) Dog
(2) Cat
Let's assume the respondend chooses (1) Dog {Q18a.shown} should give you "Dog" and {Q18a} should give you "1".
So in your case, I think using {Q18a} without shown should be correct. But best you provide a LSS export with just the relevant questions, because this helps a lot more than guessing around here.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12943
- Thank you received: 3979
3 years 5 months ago #207659
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic URGENT - Question Validation Equation for Total in Text Array
Use
Q18a==sum(self.sq_total)
with "total" as the subquestion code of this column.
In your equation the syntax of "self" is wrong.
"self" expands to all cells that match the sq_ clause (or ALL if the sq is missing).
And there is no property ".total"
Joffm
Q18a==sum(self.sq_total)
with "total" as the subquestion code of this column.
In your equation the syntax of "self" is wrong.
"self" expands to all cells that match the sq_ clause (or ALL if the sq is missing).
And there is no property ".total"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Clem53
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 5 months ago #207660
by Clem53
Replied by Clem53 on topic URGENT - Question Validation Equation for Total in Text Array
Thank you a lot for your answer. Here is a lss file with my two questions.
I tried with self, Q18b1 with underscore, with {Q18a1} and with the code of the question in url (323884X23918X226931).
I may just have a problem of syntax, it's the first time I work on LimeSurvey.
I tried with self, Q18b1 with underscore, with {Q18a1} and with the code of the question in url (323884X23918X226931).
I may just have a problem of syntax, it's the first time I work on LimeSurvey.
Attachments:
The topic has been locked.
- Clem53
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 5 months ago #207661
by Clem53
Replied by Clem53 on topic URGENT - Question Validation Equation for Total in Text Array
It works !! Thank you a lot for your answer, you're saving me !
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12943
- Thank you received: 3979
3 years 5 months ago #207662
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic URGENT - Question Validation Equation for Total in Text Array
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.