Documentation ¶
Index ¶
Constants ¶
const ( // QTypeSingleSelect represents a single select field type QTypeSingleSelect QuestionType = "single_select" // QTypeMultipleSelect represents a multiple select field type QTypeMultipleSelect = "multi_select" // QTypeRadio represents a radio field type QTypeRadio = "radio" // QTypeCheckbox represents a checkbox field type QTypeCheckbox = "checkbox" // QTypeTextArea represents a text area field type QTypeTextArea = "text_area" // QTypeInputText represents a text input field type QTypeInputText = "input_text" // QTypeEmail represents an email input field type QTypeEmail = "email" // QTypeTelephone represents a telephone input field type QTypeTelephone = "telephone" // QTypeInformation represents an information field type QTypeInformation = "information" // QTypeExternalQuestion represents a external question field type QTypeExternalQuestion = "external_question" )
Any new type, depending on the type of question, should be added to the following: - QTypeChoiceTypes if type is a choice type - QTypeTextTypes if type is a text type if the new type cant be added to either of the above, then: - create a new slice of QuestionType and add the new type to it - append the new slice to AllQuestionTypes - add a new function to check if the new type is of the new slice (e.g. IsChoiceType or IsTextType) - update this comment to include the new type :)
Variables ¶
var QTypeChoiceTypes = map[QuestionType]bool{ QTypeSingleSelect: true, QTypeMultipleSelect: true, QTypeRadio: true, QTypeCheckbox: true, }
QTypeChoiceTypes groups all choice types.
var QTypeExternalQuestions = map[QuestionType]bool{ QTypeExternalQuestion: true, }
QTypeExternalQuestions groups all external types.
var QTypeTextTypes = map[QuestionType]bool{ QTypeTextArea: true, QTypeInputText: true, QTypeEmail: true, QTypeTelephone: true, QTypeInformation: true, }
QTypeTextTypes groups all text types.
Functions ¶
func IsChoiceType ¶
func IsChoiceType(qt QuestionType) bool
IsChoiceType returns true if the question type is a choice type, false otherwise.
func IsExternalType ¶
func IsExternalType(qt QuestionType) bool
IsExternalType returns true if the question type is an external type, false otherwise.
func IsTextType ¶
func IsTextType(qt QuestionType) bool
IsTextType returns true if the question type is a text type, false otherwise.
Types ¶
type QBase ¶
type QBase struct { // Placeholder is a placeholder text. // Validations: // - optional // - min length: 1 Placeholder *string `json:"placeholder,omitempty" bson:"placeholder,omitempty" validate:"omitempty,min=1"` }
QBase is a struct that contains common fields for all types of questions.
type QuestionType ¶
type QuestionType string
QuestionType represents the different types of questions that can exist in a survey.
func ParseToQuestionType ¶
func ParseToQuestionType(v string) (QuestionType, error)
ParseToQuestionType takes a string and returns the corresponding QuestionType, or an error if the string is invalid.
func (*QuestionType) MarshalJSON ¶
func (s *QuestionType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*QuestionType) UnmarshalBSONValue ¶
func (s *QuestionType) UnmarshalBSONValue(typ bsontype.Type, raw []byte) error
func (*QuestionType) UnmarshalJSON ¶
func (s *QuestionType) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.