XLSForm tutorial: Your first form¶
ODK forms are created using spreadsheets by following the rules of a standard called XLSForm.
Using spreadsheet software to design forms is helpful because you can see a lot of information about your form on one screen, you can share your form definition with anyone, and you can use powerful spreadsheet features (formulas, drag to fill, copy and paste, automatic highlighting, and more).
Anyone who can use spreadsheet software can create a form! In less than 20 minutes, you'll build a school census survey.
If you'd like a sneak peek at what the survey looks like for data collectors, try this web preview.
See also
Goals¶
In this tutorial, you'll:
Design a short form using a variety of question types
Use the major XLSForm logic building blocks
Learn next steps to grow your skills
Ready to begin your XLSForm journey? Let's go!
Open the XLSForm template¶
You can use any spreadsheet software to create and update an XLSForm: Excel, Google Sheets, OpenOffice Calc, and more. Pick your favorite and open the XLSForm template:
Google Sheet (use File > Make a copy)
Add a required text question¶
In the
surveysheet, use the dropdown in thetypecolumn to selecttext. This will create a text question that the user can answer.In the
namecolumn, put the name of the field that will be used in analysis. Let's useschool_nameIn the
labelcolumn, put the label that you want the data collector to see:What is the school's name?In the
requiredcolumn, putyesto indicate that the question must be answered.
Add a required image question¶
In the row below the school name question, let's add a required question to capture a picture of the school.
In the
typecolumn, putimageIn the
namecolumn, putschool_front_pictureIn the
labelcolumn, putTake a picture of ${school_name}Let's also add a hint to give data collectors more information about what we want to capture. In the
hintcolumn, putInclude the front doorIn the
requiredcolumn, putyesIn the
parameterscolumn, putmax-pixels=1024to limit the length of captured image to 1024 pixels.
Add an optional location question¶
In the
typecolumn, putgeopointIn the
namecolumn, putschool_locationIn the
labelcolumn, putWhat is ${school_name}'s location?
Add an integer question that only allows positive values¶
In the
typecolumn, putintegerIn the
namecolumn, putstudent_countIn the
labelcolumn, putHow many students are enrolled?In the
requiredcolumn, putyesLet's make sure that only positive student counts are allowed. In the
constraintcolumn, put. > 0to say that the entered value (.) must be greater than 0.Let's give the data collector feedback if they enter a value that's not allowed. In the
constraint_messagecolumn, putMust be a positive number
Add a question for selecting multiple options¶
Let's add a question that asks the data collector what grades are taught at the school. We'll show three grade choices (primary, middle, high), and let the data collector select one or more.
Go to the choices sheet. This sheet is used to specify lists of choices that will be used in select questions.
Add a choice for primary grades:
In the
list_namecolumn, put the name of the list that all of our choices will belong to:gradesIn the
namecolumn, put the value that will be stored in the data that we will analyze:primaryIn the
labelcolumn, put the text that data collectors will see for the choice:Primary (1-5)
Add a choice for middle grades:
In the
list_namecolumn, putgradesto put this choice in the same list as above.In the
namecolumn, putmiddleIn the
labelcolumn, putMiddle (6-8)
Add a choice for high grades:
In the
list_namecolumn, putgradesto put this choice in the same list as above.In the
namecolumn, puthighIn the
labelcolumn, putHigh (9-12)
Go back to the
surveysheet.In the row after the
student_countquestion, putselect_multiple gradesin thetypecolumn.Note
Your spreadsheet software will show a validation warning because it doesn't know about your list name (
grades). That's expected for select questions and can be safely ignored.In the
namecolumn, putgrades_taughtIn the
labelcolumn, putWhat grades are taught?In the
requiredcolumn, putyesLet's make the choices appear horizontally next to each other. In the
appearancecolumn, putcolumns
Add a question that is shown depending on a previous answer¶
In the
typecolumn, puttextIn the
namecolumn, putadvanced_mathIn the
labelcolumn, putWhat is the most advanced math class available?In the
requiredcolumn, putyesLet's make this question appear only if the school teaches high school grades. In the
relevantcolumn, putselected(${grades_taught}, 'high')
Specify the form's title and ID¶
Go to the
settingssheet.In the
form_titlecolumn, put a title that people who interact with this form should see:Verdant school district census 2023In the
form_idcolumn, put an ID that uniquely identifies this form:school_census_23In the
instance_namecolumn, put a name that identifies each submission of this form:${school_name}
Try your form in Central¶
Note
Don't yet have an ODK Central server? 1. Get a Central server or use XLSForm Online to try your form in a web browser.
Save or download your form as an XLSX file.
Log into your Central server.
If you don't already have a Project, create one and give it a name.
Click on the New button next to
Forms.Drag and drop your XLSX file onto the file uploader.
Click the Preview button to see your form in your web browser 🎉
To see the form in the ODK Collect mobile app, click on the Testing tab and scan the QR code with Collect.
Your turn¶
Can you make the location question required?
Can you make the grade level question show only if more than 100 students are enrolled?
Can you show the grade level options vertically rather than horizontally? (Hint: The vertical layout is the default appearance for selects)
Next steps¶
Congratulations! You've now designed a form that uses most of the XLSForm building blocks. Below are more resources to grow your skills.
Deepen your understanding
Broaden your knowledge