When the kind property of Question resources has the value complex, the question property of the resource will have a JSON value that describes how the question parts must be posed to the user. This document defines the schema of those values and also the schema of the expected answer to the questions parts.
The schemas below are defined using JSON Schema.
Examples can be validated against schemas here.
Complex Question Schema:
{
"type": "object",
"properties":
{
"questions":
{
"title": "Question Parts",
"type": "array",
"items":
{
"title": "Question Part",
"type":
[
{
"description": "Textual question part",
"type": "object",
"additionalProperties": false,
"properties":
{
"kind":
{
"type": "string",
"required": true,
"enum": ["text"]
},
"persistent":
{
"type": "boolean"
},
"label":
{
"description": "The text to present to the user",
"type": "string",
"required": true
},
"key":
{
"description": "A value that identifies the question part",
"type": "string",
"required": true
}
}
},
{
"description": "Password question part - Use bullets to hide response entered by user",
"type": "object",
"additionalProperties": false,
"properties":
{
"kind":
{
"type": "string",
"required": true,
"enum": ["password"]
},
"persistent":
{
"type": "boolean"
},
"label":
{
"description": "The text to present to the user",
"type": "string",
"required": true
},
"key":
{
"description": "A value that identifies the question part",
"type": "string",
"required": true
}
}
},
{
"description": "Numerical question part",
"type": "object",
"additionalProperties": false,
"properties":
{
"kind":
{
"type": "string",
"required": true,
"enum": ["number"]
},
"persistent":
{
"type": "boolean"
},
"label":
{
"description": "The text to present to the user",
"type": "string",
"required": true
},
"key":
{
"description": "A value that identifies the question part",
"type": "string",
"required": true
}
}
},
{
"description": "Choice question part (ie. radiobuttons)",
"type": "object",
"additionalProperties": false,
"properties":
{
"kind":
{
"type": "string",
"required": true,
"enum": ["choice"]
},
"persistent":
{
"type": "boolean"
},
"key":
{
"description": "A value that identifies the question part",
"type": "string",
"required": true
},
"label":
{
"description": "Label for radiobutton group",
"type": "string",
"required": true
},
"choices":
{
"type": "array",
"required": true,
"items":
{
"title": "Choice (ie. radiobutton)",
"type": "object",
"properties":
{
"label":
{
"description": "Label for radiobutton",
"type": "string",
"required": true
},
"key":
{
"description": "Key for radiobutton",
"type": "string",
"required": true
},
"value":
{
"description": "Value for radiobutton",
"type": "string",
"required": true
}
}
}
}
}
}
]
}
}
}
}
Complex Question Example:
{
"questions":
[
{
"kind": "text",
"key": "3Npb24gZnJvbSBvdGhlciBhbmltYWxz",
"label": "What is the name of your first pet?"
},
{
"kind": "choice",
"key": "QgYnkgYSBwZXJzZXZlcmFuY2Ugb2",
"label": "To verify my account, send my temporary password to:",
"choices":
[
{"label": "SMS 415-123-4567", "key": "123", "value": "1111"},
{"label": "Email bob@somewhere.com", "key": "456", "value": "2222"},
{"label": "Email betty@somewhere.com", "key": "789", "value": "3333"}
]
}
]
}
Complex Answer Schema:
{
"type": "array",
"required": true,
"items":
{
"title": "Answer to question part",
"type": "object",
"properties":
{
"key":
{
"description": "The key for the question part",
"type": "string",
"required": true
},
"value":
{
"description": "The answer by the user for the question part",
"type": "string",
"required": true
}
}
}
}
Complex Answer Example:
[
{
"key": "3Npb24gZnJvbSBvdGhlciBhbmltYWxz",
"value": "Rover"
},
{
"key": "QgYnkgYSBwZXJzZXZlcmFuY2Ugb2",
"value": "dWVkIGFuZCBpbmRlZmF0aWdhYm"
}
]
Note: The answer example above is meant to correspond to the previous question example. The value field for the answer to the second question part will actually be the string that was used to specify the multiple choice item. To see how this is handled by the FileThis client, look at the generateGui and answer methods in the ComplexQuestionMediator.as file.