Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Random draw. Not the same result in the screen and in the responses in LS.

  • PG0124
  • PG0124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 1 week ago - 5 months 1 week ago #252090 by PG0124
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hi,

I programmed the following alternative case in LimeSurvey:

I draw a random number between 1 and 100 :

if(is_empty( randvalue ), rand(1, 100), randvalue.NAOK )    

[Question code: randvalue, question type: equation]

Then, if this number is strictly lower than 4, I want the variable DIS to be equal to 'YES' and if this number is equal or higher than 4, I want the variable DIS to be equal to 'NO':

{if(randvalue.NAOK<4,'YES','NO')}

[Question code: DIS, question type: equation]

The two questions belong to the same group. Then, I have additional equations in the group that depend on whether DIS='YES' or DIS='NO'.

The problem that I get is the following:

when I test my survey inside LimeSurvey, I sometimes get a randvalue <4 and in that case, I get on my screen DIS='YES'. Then, on my screen, all the following equations in the group that depend on whether DIS='YES' or DIS='NO' are correctly calculated.

However, when I send the results and go look at them in the answers part of my LimeSurvey, the randvalue that appears is indeed lower than 4, but DIS='NO' (instead of 'YES' in my screen when I tested the survey) and all the following equations are calculated based on the alternative DIS='NO'. Therefore, all the calculations are different from those that appeared on my screen.
See the last line in the attached image, randvalue is equal to 2, but DIS is equal to 'NO'.  

How come that the corresponding results on my screen when running the survey and those recorded in LimeSurvey are different and the latter are wrong?

This seems very odd to me and I don't know what to do, because when I run the previous code in LimeSurvey, everything works well, this is just not the correct results that are recorded in LimeSurvey.

Many thanks for your help!
Last edit: 5 months 1 week ago by PG0124.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252112 by holch
Not sure if this is the issue, but I would take out the ".NAOK" part. This stands for "No Answer is OK". But in your case, there will always be an answer, at least in this part of your equation. The NAOK is not necessary. Not sure if it can cause trouble though.

Ideally it would be great to send a LSS file with just the relevant questions, so that we can have a look at the actual survey and do some tests.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252120 by DenisChenu

Not sure if this is the issue, but I would take out the ".NAOK" part. This stands for "No Answer is OK". But in your case, there will always be an answer, at least in this part of your equation. The NAOK is not necessary. Not sure if it can cause trouble though.
 
I really think it can not break with NAOK. Always add NAOK personaly.

NO idea on issue here.

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.

Please Log in to join the conversation.

  • PG0124
  • PG0124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 1 week ago #252123 by PG0124
Thank you for your answers.

I have tried to suppress NA.OK and I still get the same problem.

I have also tried to have " " instead of ' ', in {if(randvalue<4,'YES','NO')}, what's the best?

I have also tried to suppress is_empty in {if(is_empty(randvalue),rand(1,100),randvalue.NAOK} because I don't have previous reference to randvalue.

When I run a minimal example, it works (see the two questions lsq attached). But when I run my whole survey, I always get a NO in the recorded answers in LimeSurvey even though it displayed a YES in the screen when I executed the survey.

I really don't understand what is going on here. What could explain that when recording the answers, the results are not the same than on the screen? Is it some kind of bug?

File Attachment:

File Name: limesurvey...5175.lsq
File Size:7 KB

File Attachment:

File Name: limesurvey...5176.lsq
File Size:4 KB


Many thanks for your help.

 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252126 by Joffm
Please, neither lsq nor lsg exports.
Only lss.
Copy the survey, remove everything not related to the issue, send this lss.

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • PG0124
  • PG0124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 1 week ago #252127 by PG0124
Here you are.

The thing is that the minimal example is working whereas the whole survey is not, so the minimal example is not really instructive.

Thanks

File Attachment:

File Name: limesurvey...3141.lss
File Size:26 KB

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago - 5 months 1 week ago #252135 by DenisChenu

When I run a minimal example, it works (see the two questions lsq attached). But when I run my whole survey, I always get a NO in the recorded answers in LimeSurvey even though it displayed a YES in the screen when I executed the survey.

Many thanks for your help.

 
Check if you have a condition with only one =

Check survey logic file :
 

You must have one warning only (on your equation question type)
 


 

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 months 1 week ago by DenisChenu.

Please Log in to join the conversation.

  • PG0124
  • PG0124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 1 week ago #252136 by PG0124
Thanks.

I have checked and I don't have such warning messages or any missing = in the equations.

Should the hidden equations be made mandatory or can they be optional?

For randvalue and DIS, I have :hidden1clear_defaultNsave_as_defaultN
Could it be related to my problem?

Thanks a lot!!

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252137 by DenisChenu
You check whole survey logic file ?

And about warning : you're right : no warning the way you do it …

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.

Please Log in to join the conversation.

  • PG0124
  • PG0124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 1 week ago #252139 by PG0124
Yes, I did check the whole survey logic file.

I really don't know what else I can do.

It is as if randvalue is well recorded in the LimeSurvey database but not DIS.

So the problem should be with the DIS code.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252148 by DenisChenu
Try intval(randValue)

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.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 months 1 week ago #252151 by Joffm

The thing is that the minimal example is working whereas the whole survey is not, so the minimal example is not really instructive.

Well, than you should send the whole survey

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose