Questions Data Model
Advertencia
Esta página aún no se encuentra traducida al español.
Description
Questions make up survey forms; their wide variety allows different forms for gathering input. Apart from their different input types, questions are usually divided up into pairs: one COTQuestion represents the field label displayed in the survey form and another corresponds to the data input configuration.
graph LR;
S[COTSurvey] --> C1[COTSurveyChat #1]
S --> C2[COTSurveyChat #2]
S --> C3[COTSurveyChat #3]
C1 --> Q1T[COTQuestion - Field Label]
C1 --> Q1I[COTQuestion - Input Settings]
C2 --> Q2T[COTQuestion - Field Label]
C2 --> Q2I[COTQuestion - Input Settings]
Q2I --> QE[COTQuestionExec]
C3 --> Q3[COTQuestion - Label & Input]
JSON Sample
[
// COTQuestion that represents the field label displayed in the survey form
{
"_id": "615af821b0ca3100073e4f18",
"command": {
"commands": [],
"resetIdentifiers": [],
"values": []
},
"display": [
"Example Title Display"
],
"code": [],
"isActive": true,
"isSystemModel": false,
"contentType": "application/vnd.cotalker.survey+text",
"identifier": "unique_identifier_1633351713434",
"modifiedAt": "2021-10-04T12:48:33.669Z",
"textAlign": "left"
},
// COTQuestion that represents the question's data input configuration
{
"_id": "615af821b0ca3100073e4f19",
"command": {
"commands": [],
"resetIdentifiers": [],
"isCommanded": "item_list",
"values": [
{
"_id": "615af821b0ca3100073e4f1a",
"op": "eq",
"target": "op_1"
}
]
},
"display": [],
"code": [],
"isActive": true,
"isSystemModel": false,
"contentType": "application/vnd.cotalker.survey+textinput",
"help": null,
"identifier": "unique_identifier",
"isReadOnly": false,
"max": 5000,
"min": 0,
"required": false,
"subtype": "short_text",
"modifiedAt": "2021-10-04T12:48:33.674Z"
}
]
Fields
Field | Description | Type | Notes |
---|---|---|---|
code | Depends on the contentType | string[ ] | Check code details for content types that include QR scan & NFC and Map Locations. |
command | Conditional Display settings | object | |
command.commands | Indicates which questions are commanded or depend on this question, i.e. questions using the command.isCommanded field. | string[ ] | The strings in the array corresponde to the questions identifier . |
commmand.isCommanded | Indicates if the question has Conditional Display settings. | string | The string corresponds to the commanding question's identifier . |
command.restItentifiers | string[ ] | ||
command.values | Sets the expected answers to activate the hidden question. | object[ ] | |
command.values.op | Select the comparison criteria, i.e., the operator of the conditional. | string | Options are: = , eq : Is equal to; gte : Greater than or equal; lte : Less than or equal; regex : Regular expression. |
command.values.target | Write the identifier related to the commanding answer. | string | For multiple answers, use the following syntax: (example1)|(example2) |
company | Company identification code | ObjectId<COTCompany> | |
contentType | Indicates COTQuestionContentType, i.e. survey component type | string | List of question content types |
display | Displayed question title or field label | string[ ] | Its contents depend on the contentType and whether the data model corresponds to the title section of the question. |
exec | Javascript-automated questions (QuestionExec) | object | |
exec.filter | Currently not in use. | object<COTQuestionExecFilter> | |
exec.onChange | Code runs after validate, but not after initial value is set. | object<COTQuestionExec> | See Question Execution Data Model for more information. |
exec.onDisplay | Code executes when a survey is in editing mode, i.e., when a user opens the survey from the channel, and it is displayed for answering. | object<COTQuestionExec> | See Question Execution Data Model for more information. |
exec.preload | The code executes when the survey is created. | object<COTQuestionExec> | See Question Execution Data Model for more information. |
exec.presave | Run code just before sending. | object<COTQuestionExec> | See Question Execution Data Model for more information. |
exec.postsave | If custom and internal validations are passed, the code executes after the survey is sent. | object<COTQuestionExec> | See Question Execution Data Model for more information. |
exec.validate | Code executes before internal validations and before sending the survey. This permits adding additional levels of validation (business guidelines, protocols, etc.). | object<COTQuestionExec> | See Question Execution Data Model for more information. |
identifier | Unique identification name | string | Maximum 60 characters; only lowercase letters, numbers, and underscore allowed; must be unique. |
isActive | Indicates if whether the question is active or not | boolean | |
isReadOnly | Users cannot enter or fill out a respone | boolean | |
isSystemModel | If true, it cannot be changed, even by admins | boolean | |
max | Depending on the type of question, it could represent the maximum number of components or characters permitted | number | |
min | Depending on the type of question, it could represent the minimum number of components or characters permitted | number | |
modifiedAt | Indicates when the question was last modified | ISODate | YYYY-MM-DDTHH:mm:ss.SSSZ |
required | Users must answer the question in order to submit the form | boolean | |
responses | Contains submitted data | string[ ] | Appended to model only in some contexts |
skipCodeValidation | Internal flag for legacy surveys | boolean | |
subtype | Indicates the component's input type. | string | Options depend on the survey component type or contentType |
textAlign | Indicates alignment for displayed text | string |
Deprecated
Field | Description | Type | Notes |
---|---|---|---|
symbolizes | string | ||
group | ObjectId<COTGroup> | ||
hideEmpty | boolean |
Additional Resources
- Surveys Overview: Complete description about surveys and their components (questions)
- "Questions" REST API documentation: basic "Questions" API requests
- API documentation in Swagger: complete with data models (schemas)
- COTLang: use COTLang for extracting data from models in routines
- Triggers and Contexts: more information on using data models within routines
Help
- Cotalker Platform Community: post your questions or search for previous answers given in the forum