-
Notifications
You must be signed in to change notification settings - Fork 5
Survey definition
Survey definition describes the elements of the survey and its interal logic. Survey definition is written using JSON format and consists of the following fields:
{
"title": "Test Survey",
"variables": { ... },
"items": [ ... ]
}
Form values are current question responses. If there is question with id = question1 and a change occurs for this question (i.e. text is entered), values.question1 will hold a response given to this question.
Form variables are recalculated on each value change. When a change occurs (i.e. user types a response), variables are first initialized with initial values provided in form.variables, then rules are fired which may change the variables. Rules are fired from top to bottom.
Form props are similar to values because the are persistent - when a change occurs, props are not reset to default values like variables do. In contrast to values, props are not submitted when the form is submitted. So far props are used to implement skipping sections.
Some variables have special meaning. Set variables.ID.hidden equal to 1 to hide element with a given ID.
Survey item can have any number of associated rules that handle survey logic. Each rule consists of conditions and actions. If conditions are satisfied then actions are fired. All rules are evaluated from top to bottom of the survey definition, before any update in UI takes place.
Checking for a question response value
[OPERATOR, values.ID|variables.ID|props.ID|CONST, values.ID|variables.ID|props.ID|CONST]
['==', 'values.pregnantMember', 'Yes']
['>=', 'variables.numChildren', 3],
['==', 'props.parent2.skip', 1],
Setting a variable:
['set', 'score2', 1]
Now there will be a variable variables.score2 with value of 1.
Setting element property:
['pset', 'question1.skip', 1]
This sets question1 as skipped (value is erased, question cannot be edited)
[variable.ID|client.ID|value.ID]:REDUCER1:REDUCER2
Reduces will apply transformations to the value of an operand. Reducers can be chained using : notation.
As an example client.dob:age will return age based on the date of birth of a client
Reducers can be applied to arrays (set of values for a certain column in a grid):
['set', 'youngestChildAge', 'values.children.age:min'],
will set a variables.youngestChildAge equal to smallest value in age column of a children grid
-
date:transforms timestamp (number) to a date, -
age:calculates age given the value (date) and the current date -
min:returns min value from an array -
max:returns max value from an array
Each variable that starts with score. is treated as a scoring variable and it's value will be submitted to HMIS when surevy responses are uploaded. Keep in mind that HMIS calculates the sum of all scores automatically, so there is no need to send a variable that hold the total survey score.
The following survey is made of 2 questions (number inputs)
{
"title": "Test Survey",
"id": "dummy",
"variables": {
"score.A": 0,
"score.B": 0,
`"grandtotal": 0`
},
"items": [
`{`
`"id": "question1",`
`"title": "Enter first number",`
`"type": "question",`
`"category": "number"`
`},`
`{`
`"id": "question2",`
`"title": "Enter second number",`
`"type": "question",`
`"category": "number"`
`},`
`{`
`"id": "summary",`
`"type": "text",`
`"title": "Scoring Summary",`
`"text": "First score: {{variables.score.A}}<br />Second score: {{variables.score.B}}<br /><strong>GRAND TOTAL: `
{{variables.grandtotal}}</strong>",
`"rules": [`
`{`
`"always": [`
`[`
`"set",`
`"score.A",`
`"values.question1"`
`],`
`[`
`"set",`
`"score.B",`
`"values.question2"`
`],`
`[`
`"sum",`
`"grandtotal",`
`"variables.score.A",`
`"variables.score.B"`
`]`
`]`
`}`
`]`
`}`
]
}
Surveys
To enable submission uploader an "uploader": true must be added to settings.json file E.G:
{
"public": {
"features": {
"appProfile": "home",
"uploader": true
}
}
}
Currently the Submission Uploader is only available by direct links:
/submissionUploader/list /submissionUploader/new
See exampleUploadConfig.json for the example of config to be input for Submission Uploader