SurveyQuestion
Represents a single question within a survey with support for multiple input types (text, choice, rating, scale, boolean). Includes validation rules, display ordering, and conditional logic for dynamic survey flows.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| survey | Survey | stored | Reference to the survey this question belongs to | Required |
| text | string | stored | The question text displayed to respondents Example: | Required |
| type | string | stored | Type of question determining the input method Values: Example: | Required |
| options | json | stored | Available options for choice-based questions (single-choice, multiple-choice) Example: | Optional |
| required | boolean | stored | Whether this question must be answered Example: | Optional |
| order | number | stored | Display order of the question within the survey Example: | Optional |
| helpText | string | stored | Additional help or instructions for the respondent | Optional |
| validation | json | stored | Validation rules for the answer (min/max values, patterns, etc.) | Optional |
| condition | json | stored | Conditional display rules determining when this question is shown based on previous answers Example: | Optional |
| metadata | json | stored | Additional question configuration | Optional |
| answers | SurveyAnswer[] | calculated | List of answers submitted for this question | Optional |
| answerCount | number | calculated | Number of answers received for this question | Optional |
Examples
Example 1
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Customer Satisfaction Survey"
},
"text": "How satisfied are you with our service?",
"type": "rating",
"required": true,
"order": 1,
"helpText": "Rate from 1 (very dissatisfied) to 5 (very satisfied)",
"validation": {
"min": 1,
"max": 5
}
}Example 2
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Customer Satisfaction Survey"
},
"text": "What aspects of our service did you like?",
"type": "multiple-choice",
"options": [
"Speed",
"Quality",
"Price",
"Customer Support",
"Ease of Use"
],
"required": false,
"order": 2
}Example 3
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Employee Engagement Survey"
},
"text": "How likely are you to recommend our company as a place to work?",
"type": "scale",
"required": true,
"order": 1,
"helpText": "0 = Not at all likely, 10 = Extremely likely",
"validation": {
"min": 0,
"max": 10
}
}Example 4
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Vehicle Inspection Checklist"
},
"text": "Are the brake lights functioning?",
"type": "boolean",
"required": true,
"order": 5
}Example 5
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Vehicle Inspection Checklist"
},
"text": "Describe the brake light issue",
"type": "textarea",
"required": true,
"order": 6,
"helpText": "Please describe the malfunction in detail",
"condition": {
"questionOrder": 5,
"operator": "equals",
"value": false,
"action": "show"
}
}Example 6
{
"@type": "SurveyQuestion",
"survey": {
"@type": "Survey",
"title": "Customer Satisfaction Survey"
},
"text": "What could we improve?",
"type": "textarea",
"required": false,
"order": 3,
"condition": {
"questionOrder": 1,
"operator": "lessThan",
"value": 4,
"action": "show"
}
}