Checking phone configuration in an ODK form

I'd like to share a technique to perform basic phone configuration checks within an ODK form. I've learned this from one of our partner organizations, and it seemed so broadly useful that I'm taking the liberty to share it here.

The idea is to add a set of configuration checks at the beginning of a form, like this:

type name label::English (en) required relevant
start start Start of Survey
end end End of Survey
username username Enumerator User Name
deviceid deviceid Device ID
phonenumber phonenumber Enumerator Phone Number
begin_group group_check_constraints Checking phone configuration
note note_missing_username :stop_sign: Missing user name yes normalize-space(${username}) = '' or ${username} ='NULL' or ${username} = NULL
note note_missing_phone_number :stop_sign: Missing phone number yes normalize-space(${phonenumber}) = '' or ${phonenumber} ='NULL' or ${phonenumber} = NULL
note note_incorrect_date_and_time :stop_sign: Incorrect phone date/time yes date(today()) < date('2022-06-01')
end_group

These checks will not allow data collection to proceed unless the phone configuration satisfies certain minimal constraints.

The attached file contains a more complete example, with hints that explain how the problems can be fixed.
odk-configuration-checks.xlsx (11.5 KB)

3 Likes

Great Work
THANKS HELPFUL TRICK FOR SURVEY

Thanks for sharing this, @Sjlver!

I'm surprised that you'd need to check for 'NULL' or NULL. Have you actually seen examples of devices that produce these values?

No. To be honest, I used this pretty much as I've seen it in our partner's forms, and decided to keep the check.

I guess it could happen through some QR code configuration issue (but is the user identity even configurable via QR code?)... but we might as well remove these parts of the check.

It's unlikely, maybe even impossible, that you'd get either NULL value. ${username} = '' is all you really need for that relevance check.

normalize-space() doesn't help much because it only strips leading and trailing whitespace and leaves at least one space.

1 Like