Skip to content

Assessment forms

Radu Stefanescu edited this page Apr 2, 2020 · 1 revision

Assessment form input

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "definitions": {
        "option": {
            "type": "object",
            "required": [
                "label"
            ],
            "description": "If the `value` field is missing, the answer value will become the label",
            "properties": {
                "label": {
                    "type": "string"
                },
                "value": {
                    "type": [
                        "string",
                        "boolean"
                    ]
                },
                "nextQuestionId": {
                    "type": "integer"
                }
            }
        },
        "inputOption": {
            "type": "object",
            "required": [
                "optionType"
            ],
            "properties": {
                "placeholder": {
                    "type": "string"
                },
                "optionType": {
                    "enum": [
                        "date",
                        "string",
                        "number"
                    ]
                },
                "nextQuestionId": {
                    "type": "integer"
                }
            }
        },
        "question": {
            "type": "object",
            "required": [
                "questionId",
                "nextQuestionId",
                "questionText",
                "questionType",
                "options"
            ],
            "properties": {
                "questionId": {
                    "type": "integer",
                    "unique": true
                },
                "nextQuestionId": {
                    "type": "integer"
                },
                "questionText": {
                    "type": "string"
                },
                "questionType": {
                    "enum": [
                        "SINGLE_CHOICE",
                        "MULTIPLE_CHOICE",
                        "INPUT",
                        "FINAL"
                    ]
                },
                "content": {
                    "type": "string"
                },
                "options": {
                    "type": "array",
                    "items": {
                        "oneOf": [
                            {
                                "$ref": "#/definitions/option"
                            },
                            {
                                "$ref": "#/definitions/inputOption"
                            }
                        ]
                    }
                },
                "answers": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/answer"
                    }
                }
            }
        },
        "form": {
            "type": "array",
            "minItems": 0,
            "minContains": 1,
            "title": "The form Schema",
            "description": "A collection of Questions and their relationships",
            "items": {
                "$ref": "#/definitions/question"
            }
        },
        "answer": {
            "type": "object",
            "required": [
                "options",
                "result"
            ],
            "properties": {
                "options": {
                    "type": "array",
                    "items": {
                        "type": "integer"                        
                    }
                },
                "result": {
                    "type": "integer"
                }
            }
        }
    },
    "type": "object",
    "properties": {
        "title": {
            "type": "string"
        },
        "doc_type": {
            "type": "string"
        },
        "doc_id": {
            "type": "integer"
        },
        "active": {
            "type": "boolean"
        },
        "display_order": {
            "type": "integer"
        },
        "content": {
            "type": "string"
        },
        "buttons": {
            "$id": "#/items/properties/buttons"
        },
        "firstNodeId": {
            "type": "integer",
            "description": "Id of the first question from the form (starting question id)"
        },
        "form": {
            "$ref": "#definitions/form"
        }
    }
}

Assessment form output

{
    "formId": 1,
    "timestamp": 20200327193822,
    "age": 37,
    "...other user properties...": "values..",
    "answers": [
        { 
            "id": "{{questionId1}}",
            "questionText": "{{questionText1}}",
            "answer": "{{seletedOptionValue1}}"
        },
        { 
            "id": "{{questionId2}}",
            "questionText": "{{questionText2}}",
            "answer": "{{seletedOptionValue2}}"
        },
        { 
            "id": "{{questionId3}}",
            "questionText": "{{questionText3}}",
            "answer": "{{seletedOptionValue3}}"
        },
        { 
            "id": "{{questionId4}}",
            "questionText": "{{questionText4}}",
            "answer": "{{seletedOptionValue4}}"
        }
        { 
            "id": "{{questionId4}}",
            "questionText": "{{questionText5}}",
            "answer": "{{seletedOptionValue5}}"
        }
    ]
}