models

package
v0.0.0-...-34ab1a3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Passage

type Passage struct {
	ID     primitive.ObjectID `json:"-" bson:"_id,omitempty"`    // ID в mongoDB
	UserID primitive.ObjectID `json:"-" bson:"userID,omitempty"` // ID пользователя
	TestID primitive.ObjectID `json:"-" bson:"testID,omitempty"` // ID теста

	Path   string           `json:"path" bson:"path"`     // Путь до теста
	Name   string           `json:"name" bson:"name"`     // Название теста
	Points constants.Points `json:"points" bson:"points"` // Баллов для прохождения
	Score  constants.Points `json:"score" bson:"score"`   // Набрано баллов
	Passed bool             `json:"passed" bson:"passed"` // Пройден ли тест

	Tasks []*PassageTask `json:"tasks" bson:"tasks"` // Задачи прохождения

	End time.Time `json:"end" bson:"end"` // Время, когда закончится прохождение

	CreatedAt time.Time `json:"-" bson:"createdAt"`
	UpdatedAt time.Time `json:"-" bson:"updatedAt"`
	DeletedAt time.Time `json:"-" bson:"deletedAt,omitempty"`
}

func NewPassage

func NewPassage(userID primitive.ObjectID, test *Test, tasks []*PassageTask) *Passage

func (*Passage) ActualTaskNum

func (p *Passage) ActualTaskNum() int

func (*Passage) IsLastTask

func (p *Passage) IsLastTask(num int) bool

func (*Passage) IsPassed

func (p *Passage) IsPassed() bool

func (Passage) MarshalJSON

func (p Passage) MarshalJSON() ([]byte, error)

func (*Passage) Test

func (p *Passage) Test() *TestPassage

func (*Passage) TimeSpent

func (p *Passage) TimeSpent() constants.Duration

type PassageTask

type PassageTask struct {
	Task `json:",inline" bson:",inline"` // Задача

	Points     constants.Points   `json:"points" bson:"points"`                             // Баллов за задачу
	Correct    bool               `json:"correct" bson:"correct"`                           // Правильность ответа
	AnswerUser string             `json:"answerUser,omitempty" bson:"answerUser,omitempty"` // Ответ пользователя
	TimeSpent  constants.Duration `json:"timeSpent,omitempty" bson:"timeSpent,omitempty"`   // Времени потрачено
}

func NewPassageTask

func NewPassageTask(task *Task, points constants.Points) *PassageTask

func (*PassageTask) IsAnswered

func (t *PassageTask) IsAnswered() bool

func (*PassageTask) IsCorrect

func (t *PassageTask) IsCorrect() bool

func (PassageTask) MarshalBSON

func (t PassageTask) MarshalBSON() ([]byte, error)

func (PassageTask) MarshalJSON

func (t PassageTask) MarshalJSON() ([]byte, error)

type Task

type Task struct {
	ID        primitive.ObjectID `json:"-" bson:"_id,omitempty"`               // ID в mongoDB
	Condition string             `json:"condition" bson:"condition"`           // Условие, LaTeX
	Answer    string             `json:"answer" bson:"answer"`                 // Ответ
	Tags      *TaskTags          `json:"tags,omitempty" bson:"tags,omitempty"` // Теги задачи

	Radio []string `json:"radio,omitempty" bson:"radio,omitempty"` // Варианты ответа, LaTeX

	CreatedAt time.Time `json:"-" bson:"createdAt"`
	UpdatedAt time.Time `json:"-" bson:"updatedAt"`
	DeletedAt time.Time `json:"-" bson:"deletedAt,omitempty"`
}

func NewTask

func NewTask(
	condition, answer string,
	tags *TaskTags,
	radio []string,
) *Task

func (*Task) ShuffleRadio

func (t *Task) ShuffleRadio() *Task

Если задача с выбором ответа, то перемешиваем варианты ответа.

type TaskTags

type TaskTags struct {
	Type       constants.TaskType       `json:"type" bson:"type"`             // Тип
	Complexity constants.ComplexityType `json:"complexity" bson:"complexity"` // Сложность
	Themes     []string                 `json:"themes" bson:"themes"`         // Темы задачи
}

func NewTaskTags

func NewTaskTags(taskType constants.TaskType, complexity constants.ComplexityType, themes []string) *TaskTags

func (TaskTags) MarshalJSON

func (t TaskTags) MarshalJSON() ([]byte, error)

type Test

type Test struct {
	ID          primitive.ObjectID `json:"-" bson:"_id,omitempty"`                   // ID в mongoDB
	Path        string             `json:"path" bson:"path"`                         // Путь
	Name        string             `json:"name" bson:"name"`                         // Название
	Description string             `json:"description" bson:"description"`           // Описание
	Tags        *TestTags          `json:"tags,omitempty" bson:"tags,omitempty"`     // Теги теста
	Repeat      *TestRepeat        `json:"repeat,omitempty" bson:"repeat,omitempty"` // Повторяемость теста

	Tasks    []*TestTask    `json:"tasks,omitempty" bson:"tasks,omitempty"`       // Задачи теста
	Passages []*TestPassage `json:"passages,omitempty" bson:"passages,omitempty"` // Прохождения

	CreatedAt time.Time `json:"-" bson:"createdAt"`
	UpdatedAt time.Time `json:"-" bson:"updatedAt"`
	DeletedAt time.Time `json:"-" bson:"deletedAt,omitempty"`
}

func NewTest

func NewTest(
	path, name, description string,
	tags *TestTags,
	repeat *TestRepeat,
	tasks []*TestTask,
) *Test

func (*Test) AddPassages

func (t *Test) AddPassages(passages []*TestPassage)

func (*Test) Card

func (t *Test) Card() *TestCard

type TestCard

type TestCard struct {
	Path        string       `json:"path"`                  // Путь
	Name        string       `json:"name"`                  // Название
	Description string       `json:"description"`           // Описание
	Tags        *TestTags    `json:"tags"`                  // Теги теста
	LastPassage *TestPassage `json:"lastPassage,omitempty"` // Последнее прохождение
}

func NewTestCard

func NewTestCard(path, name, description string, tags *TestTags) *TestCard

func (*TestCard) AddLastPassage

func (t *TestCard) AddLastPassage(lastPassage *TestPassage)

type TestPassage

type TestPassage struct {
	ID     primitive.ObjectID `json:"id"`     // ID прохождения
	Passed bool               `json:"passed"` // Пройден ли тест
	Start  time.Time          `json:"start"`
	End    time.Time          `json:"end"`
}

func NewTestPassage

func NewTestPassage(id primitive.ObjectID, passed bool, start, end time.Time) *TestPassage

type TestRepeat

type TestRepeat struct {
	Type         constants.RepeatType `json:"type" bson:"type"`                                     // Повторяемость
	TimeToRepeat constants.Duration   `json:"timeToRepeat,omitempty" bson:"timeToRepeat,omitempty"` // Время до повторения
}

func NewTestRepeat

func NewTestRepeat(repeatType constants.RepeatType, timeToRepeat constants.Duration) *TestRepeat

func (TestRepeat) MarshalJSON

func (r TestRepeat) MarshalJSON() ([]byte, error)

type TestTags

type TestTags struct {
	Complexity  constants.ComplexityType `json:"complexity" bson:"complexity"`     // Сложность
	Classes     constants.ClassNumbers   `json:"classes" bson:"classes,omitempty"` // Подходящие классы для теста
	Points      constants.Points         `json:"points" bson:"points"`             // Баллов для прохождения
	TimePassing constants.Duration       `json:"timePassing" bson:"timePassing"`   // Времени на прохождение
}

func NewTestTags

func NewTestTags(
	complexity constants.ComplexityType,
	classes constants.ClassNumbers,
	points constants.Points,
	timePassing constants.Duration,
) *TestTags

func (TestTags) MarshalJSON

func (t TestTags) MarshalJSON() ([]byte, error)

type TestTask

type TestTask struct {
	ID         *primitive.ObjectID      `json:"-" bson:"_id,omitempty"`       // ID задачи в mongoDB
	Complexity constants.ComplexityType `json:"complexity" bson:"complexity"` // Сложность
	Themes     []string                 `json:"themes" bson:"themes"`         // Темы задачи
	Points     constants.Points         `json:"points" bson:"points"`         // Баллов за задачу
}

func NewTestTask

func NewTestTask(
	id *primitive.ObjectID,
	complexity constants.ComplexityType,
	themes []string,
	points constants.Points,
) *TestTask

func (TestTask) MarshalJSON

func (t TestTask) MarshalJSON() ([]byte, error)

type User

type User struct {
	ID            primitive.ObjectID `json:"-" bson:"_id,omitempty"`             // ID в mongoDB
	Email         string             `json:"email" bson:"email"`                 // Почта
	EmailVerified bool               `json:"emailVerified" bson:"emailVerified"` // Подтверждена ли почта
	Password      string             `json:"-" bson:"password"`                  // Пароль hash(password + salt)
	PasswordSalt  string             `json:"-" bson:"passwordSalt"`              // Соль пароля
	Tokens        *UserTokens        `json:"-" bson:"tokens,omitempty"`          // Токены

	CreatedAt time.Time `json:"-" bson:"createdAt"`
	UpdatedAt time.Time `json:"-" bson:"updatedAt"`
	DeletedAt time.Time `json:"-" bson:"deletedAt,omitempty"`
}

func NewUser

func NewUser(email, password, passwordSalt string) *User

type UserTokens

type UserTokens struct {
	AccessToken  string `json:"accessToken" bson:"accessToken"`   // ACCESS_TOKEN
	RefreshToken string `json:"refreshToken" bson:"refreshToken"` // REFRESH_TOKEN
}

func NewUserTokens

func NewUserTokens() *UserTokens

func (*UserTokens) Refresh

func (t *UserTokens) Refresh()

Jump to

Keyboard shortcuts

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