Pages Menu
Categories Menu

Posted by on Dec 10, 2019 in Information Management, What's new | 0 comments

Advanced XLS forms coding n°3

Advanced XLS forms coding n°3

This post is a follow-up on last posts “Advanced XLS forms coding: part 1 of 2” and “Advanced XLS forms coding : part 2 of 2“.

Times flies while ODK is growing and new features appear… which means new toys for coding! Here below is a short list of a few key aspects of XLSForms coding that could help you improve your forms

How to deal with a big list of options in a select_multiple question

Designing a survey with the idea of “More quality for less cleaning” will advise you to closed questions instead of open ones for quantitative data gathering. By working with single option (select_one) or multiple option (select_multiple) questions, you may end up having to manage a (very) long list of options. It can be very tricky to find a way to display such a long list of options on a device and a significant loss of time for both the interviewer and interviewee while one scrolls to the right answer.

So what can you do? In the “Appearance” column or Kobo setting, you can use the autocomplete function. For the concerned question, it will allow the respondent to type the first letters of his/her answer and will display a filtered list based on the text that has been typed. The autocomplete function works on both Enketo and on ODK Collect.

A small tip to analyze open text questions

Analyzing open text variables is not an easy topic either. In a text question, respondents can sometimes respond with similar answers yet the responses will be recorded in different ways: for example, some might use a word and others a sentence to say the same thing. The data analysis can therefore become complicated and time consuming.

So what can you do? First of all, consider whether you really need open text questions and whether “closing” them with a list of options and an “other” option for exceptions might not be relevant. If however you really do need an open question, here is a small trick you can use. By using the contains function you can easily count answers which are composed of a specific word. You will basically add a variable with the following calculation: contains(${textVariable},’fish’) where “textVariable” is the name of the question you want to analyse and “fish” the text that you will want to count the occurrences of. Keep in mind that the function is case sensitive when you train your enumerators to capture the data.

/!\ This function has a limit though: it does not work when used for forms in several languages. For example, if your survey is in both English and French and one of your questions is “What have you eaten today?”; if you want to look for the answer “fish”, you will only be able to find the answers in English as in French it would be another term – or else you will need to use a calculation comprising both components, here: “contains(${textVariable},’fish’) or contains(${textVariable},’poisson’)”.

contains() function in the XLSForm
Data result: the column “presenceFish” corresponds to the “calculate” field with the contains() function. It indicates if there is the word (“fish” or “poisson”) in the text variable in question, by indicating “true”. Notice that the function is case sensitive

How to generate a random number

In some surveys, you can sometimes have the need to create ID numbers for respondents to facilitate the analysis. It’s really easy to do: in the “calculation” column, you can use the “once(random())” function.

How should you go about it? It can be used:

  • to create an ID for example: “once(int(899999*random())+10000)”
  • for other things such as for 2 questions setting up a 50% chance of each appearing: set up a “once(random())” calculation (that we will call “calculationname”). In the relevant column of the two questions further down the line, specify ${calculationname}>0,5 for one and ${calculationname}<=0,5 for the other.
  • the “once()” function is important so that the random calculation does not repeat if a saved form is reo-pened a second time so it is important to use the two functions together.

Keep posted for further blog posts on Advanced XLSForms coding!

Post a Reply

Your email address will not be published. Required fields are marked *

🚚 📦 We're moving!

[French below]

The content of the CartoBlog was transferred to the Information Management Resource Portal in May 2021:

Please note that the CartoBlog will be decommissioned in early 2022. From now on, we warmly encourage you to consult the tutorials, benchmarking studies and other resources directly onto the new portal.

Thank you!

🚚 📦 On déménage !

Le contenu du CartoBlog a été transféré sur l’IM Resource Portal en mai 2021 :

Veuillez noter que le CartoBlog sera désactivé au début de l’année 2022. Nous vous invitons, dès à présent, à prendre l’habitude de consulter les tutoriels, benchmarkings et autres ressources directement sur le nouveau portail.

Merci !