Welcome, Guest
Username: Password: Remember me

TOPIC: Use FLOOR to assign condition based on participant number

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96611

  • cjvanlissa
  • cjvanlissa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96636

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
Yeah, that should equal 1 but I think you have an extra bracket. Try this:
{(((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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 4 months ago by tpartner.
The administrator has disabled public write access.

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96664

  • cjvanlissa
  • cjvanlissa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96679

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
Try this to make sure you get a whole number as a result:
{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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: cjvanlissa

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96681

  • cjvanlissa
  • cjvanlissa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Ace! That did the trick! Thanks you for your help :)
The administrator has disabled public write access.

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96711

  • cjvanlissa
  • cjvanlissa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Use FLOOR to assign condition based on participant number 1 year 4 months ago #96714

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
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:
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.162 seconds
Donation Image