question

package
v0.0.0-...-0bd2313 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 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 CreateOptionRequest

type CreateOptionRequest struct {
	Text   string `json:"text,omitempty"`
	Answer bool   `json:"answer,omitempty"`
}

/// CreateOptionRequest

func (CreateOptionRequest) Validate

func (r CreateOptionRequest) Validate() error

type CreateQuestionRequest

type CreateQuestionRequest struct {
	Text          string                 `json:"text,omitempty"`
	Type          Type                   `json:"type,omitempty"`
	Duration      int64                  `json:"duration,omitempty"`
	Score         int                    `json:"score,omitempty"`
	NegativeScore int                    `json:"negative_score,omitempty"`
	Options       []*CreateOptionRequest `json:"options,omitempty"`
}

func (CreateQuestionRequest) Validate

func (r CreateQuestionRequest) Validate() error

type GetQuestionListRequest

type GetQuestionListRequest struct {
	shared.PaginatedRequest
	ExamID uint64 `json:"-"`
}

type GetQuestionListResponse

type GetQuestionListResponse struct {
	shared.PaginatedResponse
	Questions []*Question `json:"questions"`
}

type Option

type Option struct {
	ID         uint64 `xorm:"pk 'id'" json:"id"`
	QuestionID uint64 `xorm:"not null 'question_id'" json:"question_id"`
	Text       string `xorm:"varchar(250) not null" json:"text"`
	Answer     bool   `xorm:"not null" json:"answer"`

	CreatedAt time.Time `xorm:"created" json:"created_at,omitempty" field:"created_at"`
}

func NewOption

func NewOption(qid uint64, text string, answer bool) *Option

type PersistenceProvider

type PersistenceProvider interface {
	QuestionPersister() Persister
}

type Persister

type Persister interface {
	FindQuestion(context.Context, uint64) (*Question, error)
	FindQuestionOptions(_ context.Context, qid uint64) ([]*Option, error)
	FindListQuestions(ctx context.Context, eid uint64, page, pageSize int) (int64, []*Question, error)
	CreateQuestion(context.Context, *Question) error
	UpdateQuestion(context.Context, *Question, ...string) error
	RemoveQuestion(context.Context, uint64) error
}

type Question

type Question struct {
	ID            uint64        `xorm:"pk 'id'" json:"id" field:"id"`
	Examiner      uint64        `xorm:"not null" json:"examiner" field:"examiner"`
	ExamID        uint64        `xorm:"not null 'exam_id'" json:"exam_id" field:"exam_id"`
	Text          string        `xorm:"varchar(250) not null" json:"text" field:"text"`
	Type          Type          `xorm:"not null" json:"type" field:"type"`
	Duration      time.Duration `xorm:"null" json:"duration" field:"duration"`
	Score         int           `xorm:"not null" json:"score" field:"score"`
	NegativeScore int           `xorm:"not null" json:"negative_score" field:"negative_score"`

	CreatedAt time.Time `xorm:"created" json:"created_at" field:"created_at"`
	UpdatedAt time.Time `xorm:"updated" json:"updated_at" field:"updated_at"`
	DeletedAt time.Time `xorm:"deleted" json:"-" field:"-"`

	Options []*Option `xorm:"-" json:"options" field:"options"`
	// contains filtered or unexported fields
}

func NewQuestion

func NewQuestion(uid, eid uint64, text string) *Question

func (*Question) AddOption

func (q *Question) AddOption(opt *Option) *Question

func (*Question) Fs

func (q *Question) Fs() afero.Fs

func (*Question) SetDuration

func (q *Question) SetDuration(d time.Duration) *Question

func (*Question) SetNegativeScore

func (q *Question) SetNegativeScore(ns int) *Question

func (*Question) SetOptions

func (q *Question) SetOptions(opts []*Option) *Question

func (*Question) SetScore

func (q *Question) SetScore(s int) *Question

func (*Question) SetText

func (q *Question) SetText(text string) *Question

func (*Question) SetType

func (q *Question) SetType(typ Type) *Question

type Service

type Service interface {
	GetQuestion(context.Context, uint64) (*Question, error)
	GetQuestionOptions(context.Context, uint64) ([]*Option, error)
	GetQuestionList(context.Context, *GetQuestionListRequest) (*GetQuestionListResponse, error)
	CreateQuestion(context.Context, *CreateQuestionRequest) (*Question, error)
	UpdateQuestion(context.Context, *CreateQuestionRequest) error
	DeleteQuestion(context.Context, uint64) error
}

type ServiceProvider

type ServiceProvider interface {
	QuestionService() Service
}

type Type

type Type int
const (
	Descriptive Type = iota
	SingleChoice
	MultipleChoice
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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