surveygo facilitates the creation and management of surveys. It provides data structures and methods for creating
surveys, questions, and groups of questions, as well as handling validations.
- All
surveystructures will have a unique identifier callednameId. - Every reference to a
nameIdmust be unique, or in other words:- A question can only be associated with one group.
- A group can only be associated with one question or the initial set of groups
groupsOrder.
Structure representing a complete survey.
Fields
title: Survey title. (Required)version: Survey version. (Required)description: Survey description. (Optional)questions: Map of questions. (Required)groups: Map of groups. (Required)groupsOrder: Order of the groups. (Required)
Structure representing a question within a survey.
Fields
nameId: Question identifier. (Required)visible: Indicates if the question is visible. (Required)type: Type of the question. (Required)label: Question label. (Required)required: Indicates if the question is mandatory to answer. (Required)dependsOn: Conditional visibility based on other question selections. (Optional)value: Object representing the value of the question. Varies depending on the type of question. (Required)
Structure representing a group of questions in a survey.
Fields
nameId: Group identifier. (Required)title: Group title. (Optional)description: Group description. (Optional)visible: Indicates if the group is visible. (Required)isExternalSurvey: Indicates if the group is an external survey. (Optional)questionsIds: Identifiers of the questions that belong to the group. (Required)
If the group is an external survey, this field will indicate the identifier of the external survey.dependsOn: Conditional visibility based on other question selections. (Optional)
Both questions and groups can have a dependsOn field that controls their visibility based on selections in other questions.
Structure: dependsOn is an array of arrays ([][]DependsOn):
- Outer array: OR conditions (if ANY group matches, the element is visible)
- Inner array: AND conditions (ALL conditions in a group must match)
Example - Show element if user selected "terrible" rating OR (selected "meh" AND would not attend):
"dependsOn": [
[{ "questionNameId": "rating", "optionNameId": "terrible" }],
[
{ "questionNameId": "rating", "optionNameId": "meh" },
{ "questionNameId": "attendance", "optionNameId": "would_not_attend" }
]
]Note: dependsOn can only reference choice-type questions (single_select, multi_select, radio, checkbox, toggle).
Visibility during answer review: When ReviewAnswers() is called, questions and groups with unsatisfied dependsOn conditions are automatically excluded from the survey resume. This means:
- They are NOT counted in
TotalQuestionsorTotalRequiredQuestions - They do NOT appear in
UnansweredQuestions - Required questions with unsatisfied
dependsOnare not expected to be answered
single_select: Single selectmulti_select: Multiple selectradio: Single selectcheckbox: Multiple select
email: Emailtelephone: Telephonetext_area: Free textinput_text: Free textinformation: Information field, not editable
external_question: External question
Structure for all questions in the Choice group.
placeholder: Placeholder text for the question. (Optional)defaults: List of default values for the question. Each value must be a validnameIdof an option. (Optional)options: Question options. (Required)nameId: Option identifier. (Required)label: Option label. (Required)groupsIds: Identifiers of the groups to be displayed when the option is selected. (Optional)
Email (email)
placeholder: Placeholder text for the question. (Optional)allowedDomains: Allowed domains for the email. (Optional)
Telephone (telephone)
placeholder: Placeholder text for the question. (Optional)allowedCountryCodes: List of allowed country codes. (Optional)
FreeText (input_text and text_area)
placeholder: Placeholder text for the question. (Optional)min: Minimum length of the text. (Optional)max: Maximum length of the text. (Optional)
Information (information)
text: Text to be displayed. (Required)
Used to create an external questions.
External Question (external_question)
placeholder: Placeholder for the question. (Optional)defaults: List of default values for the question. (Optional)questionType: Type of the question. Refer to Types of Questions. (Required)externalType: Type of the external question. (Required)description: Description of the external question. (Optional)src: Source of the external question. (Optional)
The Asset category includes question types designed to handle various types of multimedia assets such as images, videos, audios, and documents. These types allow the incorporation and management of multimedia content in surveys.
image: For images.video: For videos.audio: For audio files.document: For documents.
Represents an image type question.
Fields
altText: Alternative text for improving accessibility. (Optional, max 255 characters)tags: Keywords associated with the image. (Optional)metadata: A map of key/value pairs for storing additional information. (Optional)maxSize: Maximum allowed file size in bytes. (Optional, must be a positive number)allowedContentTypes: List of permitted content types (e.g., "image/png", "image/jpeg"). (Optional)maxFiles: Maximum number of files that can be uploaded. (Optional, default: 1)minFiles: Minimum number of files that must be uploaded. (Optional, default: 1)
Represents a video type question.
Fields
caption: Description or additional information about the video. (Optional, max 255 characters)maxSize: Maximum allowed file size in bytes. (Optional, must be a positive number)tags: Keywords associated with the video. (Optional)metadata: A map of key/value pairs for storing additional information. (Optional)allowedContentTypes: List of permitted content types (e.g., "video/mp4", "video/ogg"). (Optional)maxFiles: Maximum number of files that can be uploaded. (Optional, default: 1)minFiles: Minimum number of files that must be uploaded. (Optional, default: 1)
Represents an audio type question.
Fields
caption: Description or additional information about the audio. (Optional, max 255 characters)maxSize: Maximum allowed file size in bytes. (Optional, must be a positive number)tags: Keywords associated with the audio. (Optional)metadata: A map of key/value pairs for storing additional information. (Optional)allowedContentTypes: List of permitted content types (e.g., "audio/mpeg", "audio/wav"). (Optional)maxFiles: Maximum number of files that can be uploaded. (Optional, default: 1)minFiles: Minimum number of files that must be uploaded. (Optional, default: 1)
Represents a document type question.
Fields
caption: Description or additional information about the document. (Optional, max 255 characters)maxSize: Maximum allowed file size in bytes. (Optional, must be a positive number)tags: Keywords associated with the document. (Optional)metadata: A map of key/value pairs for storing additional information. (Optional)allowedContentTypes: List of permitted content types (e.g., "application/pdf", "application/msword"). (Optional)maxFiles: Maximum number of files that can be uploaded. (Optional, default: 1)minFiles: Minimum number of files that must be uploaded. (Optional, default: 1)
For the complete list of available functions and methods, please refer to the files:
- operation.go: Basic survey operations (construction, validation, answers review, etc.).
- operation_de_serializers.go: Survey serialization and deserialization.
- operation_group.go: Operations on groups (add, remove, etc.).
- operation_question.go: Operations on questions (add, remove, etc.).