exam

package
v0.0.0-...-b8330c8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroStartTime = errors.New("start time is zero")
	ErrZeroTimeLimit = errors.New("time limit is zero seconds")
	ErrNoPassword    = errors.New("password is empty")
)

Functions

This section is empty.

Types

type Exam

type Exam struct {
	ID        int32
	Password  string
	Title     string
	TimeLimit time.Duration
	StartAt   time.Time
	Status    Status
}

func (*Exam) Validate

func (e *Exam) Validate() error

type Service

type Service interface {
	Save(ctx context.Context, exam Exam) (Exam, error)
	GetByID(ctx context.Context, id int32) (Exam, error)
	GetByPassword(ctx context.Context, password string) (Exam, error)
	List(ctx context.Context, size int32, page int32) ([]Exam, int32, error)
	Update(ctx context.Context, exam Exam) (Exam, error)
	Delete(ctx context.Context, id int32) error
}

func NewService

func NewService(logger *logrus.Logger, examStore Store) (Service, error)

type Status

type Status int8
const (
	StatusUnknown Status = iota
	StatusWaiting
	StatusStarted
	StatusDone
)

type Store

type Store interface {
	Save(ctx context.Context, exam Exam) (Exam, error)
	GetByID(ctx context.Context, id int32) (Exam, error)
	GetByPassword(ctx context.Context, password string) (Exam, error)
	ListAll(ctx context.Context) ([]Exam, error)
	ListPaginated(ctx context.Context, offset int32, limit int32) ([]Exam, error)
	GetTotalSize(ctx context.Context) (int32, error)
	Update(ctx context.Context, exam Exam) (Exam, error)
	Delete(ctx context.Context, id int32) error
}

func NewSQLiteStore

func NewSQLiteStore(logger *logrus.Logger, dbPool *sqlitex.Pool) (Store, error)

Jump to

Keyboard shortcuts

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