- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
set conditions doesn't work for control group and experiment group example
- nannancy
- Topic Author
- Offline
- New Member
Less
More
5 years 1 day ago #183733
by nannancy
set conditions doesn't work for control group and experiment group example was created by nannancy
Hello, we are using Limesurvey Version 2.72.6+171207. In our survey design, there are one experiment group and one control group. The implementation is as following:
question 1 [Q00] is a masked question with an equation {rand(1,2)}.
question 2 [Q01] should be shown to the respondents who has Q00==1.
question 3 [Q02] should be shown to the respondents who has Q00==2.
But it goes wrong sometimes (not always...) in the way that question 2 [Q01] is shown to me when I have Q00==2
or question 3 [Q02] is shown to me when I have Q00==1.
question 1 [Q00] is a masked question with an equation {rand(1,2)}.
question 2 [Q01] should be shown to the respondents who has Q00==1.
question 3 [Q02] should be shown to the respondents who has Q00==2.
But it goes wrong sometimes (not always...) in the way that question 2 [Q01] is shown to me when I have Q00==2
or question 3 [Q02] is shown to me when I have Q00==1.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
5 years 1 day ago #183736
by DenisChenu
Equation must be
{if(is_empty(self.NAOK,rand(1,2),self.NAOK)}
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 set conditions doesn't work for control group and experiment group example
Didn't check but with such system result can be different when loading and after load.nannancy wrote: …
question 1 [Q00] is a masked question with an equation {rand(1,2)}.
…
Equation must be
{if(is_empty(self.NAOK,rand(1,2),self.NAOK)}
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 following user(s) said Thank You: cdorin, nannancy
The topic has been locked.
- cdorin
- Offline
- Elite Member
Less
More
- Posts: 234
- Thank you received: 40
5 years 1 day ago #183745
by cdorin
Manual: manual.limesurvey.org/LimeSurvey_Manual
Bugs tracker: bugs.limesurvey.org/my_view_page.php
If you self-host and need help, contact one of our partners: limesurvey.com
Please do not contact me via PM - thank you.
Replied by cdorin on topic set conditions doesn't work for control group and experiment group example
Hmm, I can use rand(1,2) in LS3 without any issues. However, I can reproduce the above error in 2.73.
But, the solution provided by @DenisChenu works in LS 2.73 (as always ). I think an extra bracket is needed:
{if(is_empty(self.NAOK),rand(1,2),self.NAOK)}
But, the solution provided by @DenisChenu works in LS 2.73 (as always ). I think an extra bracket is needed:
{if(is_empty(self.NAOK),rand(1,2),self.NAOK)}
Manual: manual.limesurvey.org/LimeSurvey_Manual
Bugs tracker: bugs.limesurvey.org/my_view_page.php
If you self-host and need help, contact one of our partners: limesurvey.com
Please do not contact me via PM - thank you.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- nannancy
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 1 day ago #183750
by nannancy
Replied by nannancy on topic set conditions doesn't work for control group and experiment group example
Thank you so much! You save my day!
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
5 years 1 day ago - 5 years 23 hours ago #183754
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 set conditions doesn't work for control group and experiment group example
[strike]really? The extra bracket makes no sense to me... will test this.[/strike]
OK, thought about it a little more. Makes sense now.
OK, thought about it a little more. Makes sense now.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 5 years 23 hours ago by holch.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
5 years 12 hours ago - 5 years 12 hours ago #183769
by DenisChenu
Maybe it's happen because you have «chance» than rand(1,2) give the same value when page loading 1st time and page loading 2nd time ?
PS : thanks for bracket …
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 set conditions doesn't work for control group and experiment group example
Strange ?cdorin wrote: Hmm, I can use rand(1,2) in LS3 without any issues. …
Maybe it's happen because you have «chance» than rand(1,2) give the same value when page loading 1st time and page loading 2nd time ?
PS : thanks for bracket …
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.
Last edit: 5 years 12 hours ago by DenisChenu. Reason: thanks for bracket …
The following user(s) said Thank You: cdorin
The topic has been locked.
- nannancy
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 7 hours ago #183801
by nannancy
Replied by nannancy on topic set conditions doesn't work for control group and experiment group example
Hey! Since you said that rand(1,2) give the same value when page loading 1st time and page loading 2nd time, I have one question: the wrong survey was sent out and 100 respondents have accessed it. For every respondent, does the rand(1,2) work correctly if we assume all of them access the page 1st time? Thank you very much in advance!
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
5 years 6 hours ago #183806
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 set conditions doesn't work for control group and experiment group example
The "rand(1,2)" is triggered EVERY time any one accesses the page where this is hidden. It doesn't matter if it is 100 different people or one person 100 times.
So this is not the problem. The problem with using only "rand(1,2)" is that if the same person accesses the page again (for whatever reason, maybe because they went back in the survey, the closed the survey and opened it again, etc.), the randomization will be triggered again for them. So it could happen that they received "1" as their random number, continued, saw the questions that will be shown with "1" and then they went back. Then the randomization process would be triggered again and there is a 50% chance that they now will receive "2" as their random number and when they continue they suddenly see the other questions...
To avoid this, you should use the code given by Denis, as it checks if the random number has already been set for this session (this does not impact other people on different sessions - other devices/browsers, only this current session). If the random number has already been set, then it would just take this number and not create a new one, if the number has not been set, then there will be created a random number.
So this is not the problem. The problem with using only "rand(1,2)" is that if the same person accesses the page again (for whatever reason, maybe because they went back in the survey, the closed the survey and opened it again, etc.), the randomization will be triggered again for them. So it could happen that they received "1" as their random number, continued, saw the questions that will be shown with "1" and then they went back. Then the randomization process would be triggered again and there is a 50% chance that they now will receive "2" as their random number and when they continue they suddenly see the other questions...
To avoid this, you should use the code given by Denis, as it checks if the random number has already been set for this session (this does not impact other people on different sessions - other devices/browsers, only this current session). If the random number has already been set, then it would just take this number and not create a new one, if the number has not been set, then there will be created a random number.
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: DenisChenu
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
5 years 6 hours ago - 5 years 6 hours ago #183807
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 set conditions doesn't work for control group and experiment group example
Even if user don't use back:
By program
1. We call _validateQuestion when page load : rand is done #1
2. Unsure : page is shown, and the rand JS is done (unusure on this point)
3. We call _validateQuestion before calling next page (move next) : rand is done #2
The 2 solutions i know :
1. Use rand Equation in a group without any question, and disallow move previous.
2. Use the is_empty system
By program
1. We call _validateQuestion when page load : rand is done #1
2. Unsure : page is shown, and the rand JS is done (unusure on this point)
3. We call _validateQuestion before calling next page (move next) : rand is done #2
The 2 solutions i know :
1. Use rand Equation in a group without any question, and disallow move previous.
2. Use the is_empty system
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.
Last edit: 5 years 6 hours ago by DenisChenu.
The following user(s) said Thank You: cdorin
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
5 years 5 hours ago #183810
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 set conditions doesn't work for control group and experiment group example
I would always prefer the "is_empty" system. It is quite simple and it effective. Why complicate things.
Thanks for the additional occasions where the simple rand() approach could cause trouble.
Thanks for the additional occasions where the simple rand() approach could cause trouble.
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.