Documentation ¶
Index ¶
- type CreateOptionRequest
- type CreateQuestionRequest
- type GetQuestionListRequest
- type GetQuestionListResponse
- type Option
- type PersistenceProvider
- type Persister
- type Question
- func (q *Question) AddOption(opt *Option) *Question
- func (q *Question) Fs() afero.Fs
- func (q *Question) SetDuration(d time.Duration) *Question
- func (q *Question) SetNegativeScore(ns int) *Question
- func (q *Question) SetOptions(opts []*Option) *Question
- func (q *Question) SetScore(s int) *Question
- func (q *Question) SetText(text string) *Question
- func (q *Question) SetType(typ Type) *Question
- type Service
- type ServiceProvider
- type Type
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"` }
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 (*Question) SetNegativeScore ¶
func (*Question) SetOptions ¶
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
}
Click to show internal directories.
Click to hide internal directories.