question

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseQuestion

type BaseQuestion struct {
	// NameId is the identifier of the question.
	// Validations:
	// - required
	// - valid name id
	NameId string `json:"nameId,omitempty" bson:"nameId,omitempty" validate:"required,validNameId"`

	// Visible is a flag that indicates if the question is visible.
	Visible bool `json:"visible,omitempty" bson:"visible,omitempty"`

	// QTyp is the type of question, such as single_select, multi_select, radio, checkbox, or text_area.
	// Validations:
	// - required
	// - must be a valid question type
	QTyp types.QuestionType `json:"type,omitempty" bson:"type,omitempty" validate:"required,questionType"`

	// Label is a label for the question.
	// Validations:
	// - required
	// - min length: 1
	Label string `json:"label,omitempty" bson:"label,omitempty" validate:"required,min=1"`

	// Required indicates whether the question is required. Defaults to false.
	Required bool `json:"required,omitempty" bson:"required,omitempty"`
}

BaseQuestion is a struct that contains common fields for all types of questions in a survey.

type Group

type Group struct {
	// NameId is the name id of the group.
	// Validations:
	// - required
	// - valid name id
	NameId string `json:"nameId,omitempty" bson:"nameId,omitempty" validate:"required,validNameId"`

	// Title is the title of the group.
	// Validations:
	// - optional
	Title *string `json:"title,omitempty" bson:"title,omitempty" validate:"omitempty"`

	// Description is the description of the group.
	// Validations:
	// - optional
	Description *string `json:"description,omitempty" bson:"description,omitempty" validate:"omitempty"`

	// Visible is a flag that indicates if the group is visible.
	Visible bool `json:"visible,omitempty" bson:"visible,omitempty"`

	// IsExternalSurvey is a flag that indicates if the group is an external survey.
	// When a group is an external survey, it means that:
	// - QuestionsIds length must be 1
	// - The question will be an external survey question id
	// Validations:
	// - validIfExternalSurvey
	IsExternalSurvey bool `json:"isExternalSurvey,omitempty" bson:"isExternalSurvey,omitempty" validate:"validIfExternalSurvey"`

	// QuestionsIds is a list of question ids that are associated with this group.
	// Validations:
	//	- required
	// 	- each question id must be valid:
	//		* length must be greater than 0
	QuestionsIds []string `json:"questionsIds,omitempty" bson:"questionsIds,omitempty" validate:"required,dive,min=1"`
}

Group is a struct that represents a group of questions.

func (*Group) AddQuestionId

func (g *Group) AddQuestionId(nameId string, position int)

AddQuestionId adds the question with the specified name ID to the group. Args: - nameId: the name ID of the question to add. - position: the position where to add the question. If position is -1, the question will be added at the end of the group.

func (*Group) RemoveQuestionId

func (g *Group) RemoveQuestionId(nameId string) bool

RemoveQuestionId removes the question with the specified name ID from the group. Returns true if the question was removed, false otherwise.

type Question

type Question struct {
	// BaseQuestion contains common fields for all types of questions.
	BaseQuestion `bson:",inline"`

	// Value is the value of the question, which can be of different types depending on the type of question.
	// Validations:
	// - required
	Value any `json:"value,omitempty" bson:"value,omitempty" validate:"required"`
}

Question is a struct that represents a question in a survey.

func (*Question) UnmarshalBSONValue

func (q *Question) UnmarshalBSONValue(typ bsontype.Type, b []byte) error

func (*Question) UnmarshalJSON

func (q *Question) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL