Does ODK 2.0 have do / while / for loop syntax?

I am trying to locate documentation for how to program an ODK Survey form, and what kind of syntax it uses, and how to convert an XlsForm to a json file. Would someone be able to point me towards that documentation?

Also, does ODK 2.0 allow you to write do / while / for loops? If I have a house roster form, and then I have a individual questionnaire, how might I in ODK 2.0, in the middle of my individual questionnaire, loop through the household form (for example, maybe I am asking about the individual’s children).

hi @Joseph_E_Flack_IV

you can go through this documentation it will help you Question Types - ODK Docs

thank you
fabla

@Fabla thanks for your reply. However that link is actually to the ODK 1 form documentation, which doesn’t apply to ODK 2.0. That link is perfect for ODK Collect.

@Joseph_E_Flack_IV here is the link to the relevant ODK 2.0 documentation:

  • XLSXConverter documentation link.
    This link should answer most of your questions. It goes into lots of detail about the syntax of XLSX forms and how it translates to ODK Survey behavior.

  • Application Designer documentation link.
    App Designer contains the XLSXConverter in a tab. This is what you run to convert your XLSX form into JSON, as well as the other supporting files. In particular you should check out the “ODK Survey: Desining a Form” section.

  • Overall ODK 2.0 documentation link and ODK Survey documentation link for reference

Regarding loops, yes you can achieve that functionality. You can define your control flow entirely to your own needs. Take a look at the condition and clause columns in the XLSX converter documentation. As an example, you could specify an if statement in the clause column and then use Javascript to check if you have collected information on all of the children. You can specify which section to perform with the “do section” command.

You can branch to different sections of your Survey, or you can define a separate subform that you can launch (repeatedly if desired). Check out the “More Advanced Branching” section of the XLSX converter documentation. There is also an example of this that is packaged with the App Designer download. Unzip that folder and check out the household and household_member forms. I believe these are quite similar to your use case. You can find them inside the App Designer unzipped directory under the following paths:

  • app/config/tables/household/forms/household/
  • app/config/tables/household_member/forms/household_member/

Check out the ODK Survey documentation for more information about using those forms.

Hopefully this helps! Please follow up if you have more questions.

Jeff Beorse
Eir Birch LLC

You could also use the goto command with an if statement. I would recommend using the most appropriate tool for the job like subforms if it is multiple questions.

@Jeff_Beorse gave a great set of suggestions.

Thank you all for your responses.

@Jeff_Beorse
Thanks to you in particular. I feel like you’ve just walked me right into a treasure trove of knowledge. Is there a reason why the official ODK 2.0 documentation is still under the -dev deployment of the opendatakit.org organization?

@Joseph_E_Flack_IV The ODK website is part of the transition that the ODK project is currently going through. You can read more about it in this forum thread.

The version of the website with the most current ODK 2.0 documentation is the “alpha” website referenced in @W_Brunette’s post. I imagine that documentation will end up on whatever the final version of the website is, but that’s really up to the PMC.

Sorry I don’t have a very satisfying answer to the question.

You have suggested to design subform for repeated sections similar like household form.
I tested household form but I don’t know that how can I validate each field based on other filled sub-forms fields?

Hey Hameedullah,

I know your question is directed at Jeff, but I’m curious if you could attach your form or otherwise describe the question you are having difficulty validating?

Here i have uploaded the screenshot of my form screen: