Welcome to the LimeSurvey Community Forum

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

Variables type changes when jumping to next question group

  • julianschuessler
  • julianschuessler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #207458 by julianschuessler
I've been struggling with a really strange behavior.

I've boiled it down to this (see attached survey):

1. Question group: User inputs household size. I compute a variable from this via an equation.
2. Question group: User inputs income (plus a few other things). I compute a standardized income from this ("ComputeIncome"). It is definitely a number that I can further computer with other things (like "Position")

This all works fine.

3. Question group: Here I need to do further things with ComputeIncome. But it seems Limesurvey changes its variable type. While it's value seems to stay the same, I cannot anymore e.g. divide it by 2 (result is NAN).

Here is the thing: This behavior in the 3. question group only occurs when question groups are loaded on different webpages. When I run the whole survey on one page, everything works as expected.

Does anyone have any idea how I can solve this problem?
Attachments:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207461 by Joffm
In your example there is no variable called "IncPosEstimate" which is used in equation "Bias".
Please send the revised survey.

Furthermore you should revise your equations.
You use obsolete conditions
{if(RandEU.NAOK == "true", if(ComputeIncome.NAOK/ComputeHHfactor.NAOK <= 8406, 0, if(ComputeIncome.NAOK/ComputeHHfactor.NAOK > 8406 and ComputeIncome.NAOK/ComputeHHfactor.NAOK < 10961, 10, if(ComputeIncome.NAOK/ComputeHHfactor.NAOK >= 10961 and ...

The red part is not necessary because it is the FALSE part of the first comparison. This first failed therefore IS greater than 8406.

And with numerical codes instead of "A1", "A2", ... the first equation could be done with one simple formula:
{(SDHHSize+1)* 0.5 - SDChildren*0.2}

Some first findings:
equation RandEU should be changed; as RandEUStep has a fixed value you my just say {if(RandEUStep>3,1,0)}.
equation ComputePosition: there is no value if RandEU!=true -> undefined.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: julianschuessler
The topic has been locked.
  • julianschuessler
  • julianschuessler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago - 3 years 5 months ago #207473 by julianschuessler
Replied by julianschuessler on topic Variables type changes when jumping to next question group
Thank you Joffm, this is really helpful.I've changed the things you suggested.The basic behavior has not changed. In the final question group, Limesurvey correctly displays the value of ComputeIncome and HHsize, but apparently is unable to perform computations on them (like divide them by 2). Again, it works as expected once I choose to show the survey on one page instead of separate pages.
Last edit: 3 years 5 months ago by julianschuessler.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207482 by DenisChenu
Because it's NOT really an integer …

Solution 1 (checked): use dedicated equation part : you'r sure you din't have HTML extra part : manual.limesurvey.org/Question_type_-_Eq...ation_.28equation.29
Solution 2 (not tested) : use Number only : manual.limesurvey.org/Question_type_-_Eq...y_.28numbers_only.29

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: julianschuessler
The topic has been locked.
  • julianschuessler
  • julianschuessler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #207492 by julianschuessler
Replied by julianschuessler on topic Variables type changes when jumping to next question group
Thanks Denis, this was a very good hint. After deleting the HTML comments, everything works.

I am still irritated because the HTML comments per se did not contain any mistakes, as far as I can see, and also the bug did not occur whenever I would run the survey on one page. So it seems it to me it's a Limesurvey bug.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207503 by DenisChenu
For me : there are an issue too :
Seem data saved in DB are OK (are only number), but unsure …

Can you try without the comment only ? Just leave p tage ?

Then : you can report the issue about comment difference :)

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 topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose