response

package
v0.0.0-...-2f38b72 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer interface {
	Question() uuid.UUID
}

type AnswerBase

type AnswerBase struct {
	// QuestionId is the unique identifier of the question this answer is for.
	QuestionId uuid.UUID
}

func (AnswerBase) Question

func (a AnswerBase) Question() uuid.UUID

type CheckboxAnswer

type CheckboxAnswer struct {
	AnswerBase
	// Values is the list of selected options.
	Values []int
}

type FormData

type FormData struct {
	Id        uuid.UUID
	VersionId uuid.UUID
	Questions []QuestionData
}

type QuestionData

type QuestionData struct {
	Id          uuid.UUID
	Order       int
	Type        form.QuestionType
	OptionCount int
}

type RadioAnswer

type RadioAnswer struct {
	AnswerBase
	// Value is the selected option.
	Value int
}

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func NewPgRepo

func NewPgRepo(dbpool *pgxpool.Pool) *Repo

func (*Repo) SaveResponse

func (r *Repo) SaveResponse(ctx context.Context, resp Response) error

type Response

type Response struct {
	// ID is the unique identifier of the response.
	Id uuid.UUID
	// FormId is the unique identifier of the form this response is for.
	FormVersionId uuid.UUID

	// Answers is the list of answers to the questions in the form.
	Answers []Answer

	SubmittedAt time.Time
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repo *Repo) *Service

func (*Service) ParseResponse

func (s *Service) ParseResponse(formData FormData, resp map[string][]string) (Response, error)

func (*Service) SaveResponse

func (s *Service) SaveResponse(ctx context.Context, resp Response) error

type TextAnswer

type TextAnswer struct {
	AnswerBase
	// Value is the text answer.
	Value string
}

Jump to

Keyboard shortcuts

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