How to check if a response is Even or Odd

Hi ODK Devs,

This should be fairly simple but i have no idea how to implement this in
ODK, i want to check if a user response (lets say from a range of 1 - 10)
is even or odd.

Regards,
Ayub

This question is more suitable for opendatakit@

opendatakit-developers@ is for people working on modifying the Java code,
not crafting forms.

This is a modulo function, represented as '%', which is a binary operator
for integer values. You should be able to do:

if(${fieldA} % 2 = 1, 'odd', 'even')

Modulo, e.g., A % 2 will equal the remain after A is divided by 2.

The set of possible remainders for A % 2 are 0 and 1. In this case, a
remainder of 0 means the value is even, a remainder of 1 means it is odd.

ยทยทยท On Sun, Jun 8, 2014 at 10:59 PM, Ayub wrote:

Hi ODK Devs,

This should be fairly simple but i have no idea how to implement this in
ODK, i want to check if a user response (lets say from a range of 1 - 10)
is even or odd.

Regards,
Ayub

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Hi Mitch,

I should have posted the question in opendatakit@, will keep that in mind.

Here is what works:

relevant="(/data/number mod 2 = 1)"
relevant="if(/data/number mod 2 = 1, true(), false())"

This doesn't work: (% gives unknown operator error in validate)

relevant="if(/data/number % 2 = 1, true(), false())"

Regards,
Ayub