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
survey
sheet, use the dropdown in thetype
column to selecttext
. This will create a text question that the user can answer.In the
name
column, put the name of the field that will be used in analysis. Let's useschool_name
In the
label
column, put the label that you want the data collector to see:What is the school's name?
In the
required
column, putyes
to 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
type
column, putimage
In the
name
column, putschool_front_picture
In the
label
column, 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
hint
column, putInclude the front door
In the
required
column, putyes
In the
parameters
column, putmax-pixels=1024
to limit the length of captured image to 1024 pixels.
Add an optional location question¶
In the
type
column, putgeopoint
In the
name
column, putschool_location
In the
label
column, putWhat is ${school_name}'s location?
Add an integer question that only allows positive values¶
In the
type
column, putinteger
In the
name
column, putstudent_count
In the
label
column, putHow many students are enrolled?
In the
required
column, putyes
Let's make sure that only positive student counts are allowed. In the
constraint
column, put. > 0
to 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_message
column, 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_name
column, put the name of the list that all of our choices will belong to:grades
In the
name
column, put the value that will be stored in the data that we will analyze:primary
In the
label
column, put the text that data collectors will see for the choice:Primary (1-5)
Add a choice for middle grades:
In the
list_name
column, putgrades
to put this choice in the same list as above.In the
name
column, putmiddle
In the
label
column, putMiddle (6-8)
Add a choice for high grades:
In the
list_name
column, putgrades
to put this choice in the same list as above.In the
name
column, puthigh
In the
label
column, putHigh (9-12)
Go back to the
survey
sheet.In the row after the
student_count
question, putselect_multiple grades
in thetype
column.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
name
column, putgrades_taught
In the
label
column, putWhat grades are taught?
In the
required
column, putyes
Let's make the choices appear horizontally next to each other. In the
appearance
column, putcolumns
Add a question that is shown depending on a previous answer¶
In the
type
column, puttext
In the
name
column, putadvanced_math
In the
label
column, putWhat is the most advanced math class available?
In the
required
column, putyes
Let's make this question appear only if the school teaches high school grades. In the
relevant
column, putselected(${grades_taught}, 'high')
Specify the form's title and ID¶
Go to the
settings
sheet.In the
form_title
column, put a title that people who interact with this form should see:Verdant school district census 2023
In the
form_id
column, put an ID that uniquely identifies this form:school_census_23
In the
instance_name
column, 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