Welcome to the LimeSurvey Community Forum

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

Use FLOOR to assign condition based on participant number

  • cjvanlissa
  • cjvanlissa's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96611 by cjvanlissa
Dear readers, I am having a problem with the following. In my survey, I assign people to condition based on their participant number, using the FLOOR function. However, some numbers are SKIPPED completely, and I can't pinpoint the error. Here is the process I use:

Participants' number is filled in in a question called 'ppno'
The next question is equation type, called 'condition'. The equation is {((((ppno/3)-(FLOOR(ppno/3)))*3)}

Then there are 3 questions, each of which is a different condition of my experimental manipulation. The questions have these relevance equations:

condition == 0
condition == 1
condition == 2

Now, when I entered participant number 211, I first noticed the problem that it SKIPS these questions completely. Yet I don't see how the outcome of ((((211/3) - (floor(211/3)))*3) could be anything other than 0|1|2

Could anyone point me in the right direction please? I've been at this for 3 hours and it seems like it should be simple!

Thank you so much,
Caspar
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago - 10 years 9 months ago #96636 by tpartner
Yeah, that should equal 1 but I think you have an extra bracket. Try this:
Code:
{(((ppno/3) - (floor(ppno/3))) * 3)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 9 months ago by tpartner.
The topic has been locked.
  • cjvanlissa
  • cjvanlissa's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96664 by cjvanlissa
Thanks for your response tpartner! Unfortunately, the way you wrote it up is exactly like it is in my actual survey. I mistyped it in my original post.

To be clear: the problem is not that this code NEVER works, the problem is that the code doesn't work for SOME values of ppno. The first time the code failed me is when using ppno = 211. The problem is consistent, i.e. it NEVER works with ppno = 211, and I've since then discovered it also fails with some other numbers.

Any idea how it could be that the code fails only for some values of 'ppno'?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96679 by tpartner
Try this to make sure you get a whole number as a result:
Code:
{ceil(((ppno/3) - (floor(ppno/3))) * 3)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: cjvanlissa
The topic has been locked.
  • cjvanlissa
  • cjvanlissa's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96681 by cjvanlissa
Ace! That did the trick! Thanks you for your help :)
The topic has been locked.
  • cjvanlissa
  • cjvanlissa's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96711 by cjvanlissa
Actually, still not working. It worked for 211, but a different ppno (95) still resulted in the questionnaire skipping the conditional questions.

This is really bizarre; the code has been working perfectly for months, and now suddenly it results in major issues. Even updating Limesurvey did not make a difference.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96714 by tpartner
I get exactly 3 with a ppno of 95.

Try putting something like this in a text-display question to see the equation component values:
Code:
ppno/3: {(ppno.shown/3)}
floor(ppno/3): {floor(ppno.shown/3)}
(ppno/3) - (floor(ppno/3): {((ppno.shown/3) - (floor(ppno.shown/3)))}
ceil(((ppno/3) - (floor(ppno/3))) * 3): {ceil(((ppno.shown/3) - (floor(ppno.shown/3))) * 3)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose