Randomization using respondents phone number

Dear all,

I have one question.....i have a list of phone numbers(contact numbers) of respondents and there are questions. What i want is if the phone number last digit is odd i want some group of questions to be asked, if the last digit is even i want another group of question to be asked. Is there a way for this? Please help me

Thank you

Yup, you have all the tools available to determine this from https://docs.getodk.org/form-operators-functions/. Roughly the process will be:

  • string-length() to find the length of your phone number string
  • substr() to get the last character, using the length of the string from above [note, fist char of a string has index 0, not 1!]
  • number() to convert this digit to an actual number
  • the XPath mod function to divide this number by 2 to get the remainder (either 0 if even or 1 if odd)
  • and finally boolean() to convert this number to true (odd) or false (even)

XLSForm implementation of above is exercise left to the reader... :wink:


I love this question!
I've used something like this in the past where I wanted a "quality control" question to be asked 10% of the time, for example, just by getting the form to generate a random number, and then based on the number generated, ask a certain question (or not).

It's then not based on a number that the user inputs (such as a phone number), but based on a random number generated by the form itself.

So that's also another way to do this randomization. Also like the idea of using the phone number...