Client developers design a survey in JSON and provide either an API that can be used to retrieve this JSON or a JSON file located in a particular directory that can be read when processing responses.
Survey Response Documents
The survey responses are submitted to the server as a JSON object. See example below:
The tables where LabKey stores the survey responses are dynamic generated, meaning the tables are automatically created based on a given survey design. For this reason, the way you structure your survey questions, determines the list schemas on the server, which in turn determines how analysts query the data.
Electronic data capture surveys are composed of a variety of question types. Review the options available in the core LabKey documentation:
Using the "Other" Option
Mobile App surveys support the option to have questions with an "Other" answer option for multiple choice questions, including those where many answers are allowed. The submitting user checks "Other" and also has the option to enter arbitrary text.
For example, a question "What medications are you taking?" could list a few common options, as well as an "Other" option for unlisted entries. Parameters in the definition of an "other" question are:
- textfieldReq: (Boolean) Whether custom text input is shown to the respondent
- placeholder: (String) The string to show in an empty field (prior to entry).
- isMandatory: (Boolean) Whether completion of the text field is required if the Other option is checked.
The metadata for a multiple choice question including an "Other" option will take this form:
"text" - String
"value" - String
"detail" - String; nil
"exclusive" – Boolean
"destination" - String
"textfieldReq" - Boolean
"placeholder" - String
"selectionStyle" - String; Single/Multiple
The name of all the selected values, including the "Other" option is stored in the main result column. Any text entered as part of the Other option is stored in another column named with a _text extension. i.e. "ResponseColumn_text". If the user did not enter text, or if the Other option hasn’t been selected, this column is null.
Submitting Survey Responses to the Server
Mobile apps submit data to the server using a POST URL, with the body of the POST being a JSON survey response document.