Skip to content

Creating JSON Checklists

Spencer McIntyre edited this page Jun 25, 2015 · 5 revisions

The Operator application utilizes JSON files to store the format and content of various checklists. The application allows the user to use a JSON file stored on their device as a template to generate the checklist. These checklists are saved to the device and may either be reloaded into the Operator application or pulled off of the device.

#Creating A New JSON File# Each checklist requires a title object so that the Operator Application knows to differentiate the checklist from others. The title object should be in the following format:

"title":"Title Of My Checklist"

There are three Name/Value pairs that may be stored in each object. Two of these Name/Value pairs question and type are required for every object. Valid response types can be found here. The third Name/Value pair, option is optional for all input types excluding Checkboxes when writing a new JSON file but will always be generated when the Operator application creates a JSON file.

A sample JSON file:

{  
    "title":"Title Of My Checklist",
    "questions": [
        {"question": "Sample Text Input Question", "type": "text"},  
        {"question": "Sample Number Input Question", "rtype": "num"},  
        {"question": "Sample Yes/No Input Question", "type": "yes_no"},  
        {"question": "Sample Date Input Question", "type": "date"},  
        {"question": "Sample Checkbox Question", "type": "check", "options": [  
            "First Option",  
            "Second Option",  
            "Other Option"
        ]} 
    ], 
}

#Supported Input Types# The Checklist feature supports five different types of user input. Each input type has a unique character identifier that is used by the Operator application to determine what input type to display.

The input types and their associated character identifiers are:

Text Input: text
Numerical Input: num
Yes/No Input: yes_no
Checkboxes: check
Date Input: date

These input types are demonstrated in more detail below.

###Text Input### Text Input types create a text field that support standard string inputs.

The implementation of the Text Input type is shown below:

{"question": "Sample Text Input Question", "type": "text"}

###Numerical Input### Numerical Input types look identical to and inherit from the Text Input type. However, this type will only accept integers and decimal points.

The implementation of the Numerical Input type is shown below:

{"question": "Sample Numerical Input Question", "type": "num"}

###Yes/No Input### The Yes/No Input type contains a pair of radio buttons. The radio buttons are grouped together such that only one may be selected at any time.

The implementation of the Yes/No Input type is shown below:

{"question": "Sample Yes/No Input Question", "response_type": "yes_no"}

###Checkbox Input### The Checkbox Input type creates a series of checkboxes based upon options provided in the JSON file. This is the only input type that requires an options element when creating the template file for a checklist. The options element should contain an array with strings for each individual option. Additionally, any option that starts with the string 'Other' will generate a Text Input field for the user.

The implementation of the Checkbox Input type is shown below:

{"question": "Sample Checkbox Question", "response_type": "check", "options": [  
    "First Option",  
    "Second Option",  
    "Other Option"  
]},

###Date Input### The Date Input type creates spinners for the Month, Day, and Year. Users are able to change each spinner interdependently of the other two.

The implementation of the Date Input type is shown below:

{"question": "Sample Date Input Question", "response_type": "date"}

#Saving A Checklist# Once the user presses the Submit button, the checklist is processed into a new JSON file with the same format as the initial template.

Checklists are saved to the following location:
/sdcard/operator/checklists/responses/
Files are stored using the following naming convention:
HH:MM_mm-dd-YYYY.json

Clone this wiki locally