types

package
v0.0.0-...-bc49051 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PromptStats

type PromptStats struct {
	Prompt         string
	Weight         float64
	Total          int
	Correct        int
	ElapsedAverage time.Duration
	ElapsedMin     time.Duration
	ElapsedMax     time.Duration
	ElapsedP75     time.Duration
	ElapsedP90     time.Duration
	ElapsedP95     time.Duration
	ElapsedTimes   []time.Duration
}

PromptStats hold statistics for a prompt.

func (PromptStats) PercentCorrect

func (ps PromptStats) PercentCorrect() float64

PercentCorrect returns the percentage correct.

type Quiz

type Quiz struct {
	// ID is a unique identifier for the quiz.
	ID uuid.UUID `db:"id,pk"`
	// UserID is the user the quiz corresponds to.
	UserID uuid.UUID `db:"user_id"`
	// CreatedUTC is the time the quiz was created.
	CreatedUTC time.Time `db:"created_utc"`
	// LastAnsweredUTC is the last time the quiz was answered.
	LastAnsweredUTC time.Time `db:"last_answered_utc"`
	// Hiragana indicates if we should include prompts from the hiragana set.
	Hiragana bool `db:"hiragana"`
	// Katakana indicates if we should include prompts from the katakana set.
	Katakana bool `db:"katakana"`
	// MaxQuestions is the maximum number of questions to ask per quiz.
	MaxQuestions int `db:"max_questions"`
	// MaxPrompts is the maximum number of prompts to pull from either prompt set (or in total)
	MaxPrompts int `db:"max_prompts"`
	// MaxRepeatHistory is the debounce history list length.
	MaxRepeatHistory int `db:"max_repeat_history"`
	// Results are the individual prompts and answers.
	Results []QuizResult `db:"-"`
	// Prompts are the individual mappings between kana and roman to quiz.
	Prompts map[string]string `db:"prompts,json"`
	// PromptWeights are used for selection bias based on incorrect answers.
	PromptWeights map[string]float64 `db:"prompt_weights,json"`
	// PromptHistory are the recent prompts used to debounce them.
	PromptHistory []string `db:"prompt_history,json"`
}

Quiz is a quiz.

func NewTestQuiz

func NewTestQuiz(userID uuid.UUID) *Quiz

NewTestQuiz returns a new test quiz.

func (Quiz) IsZero

func (q Quiz) IsZero() bool

IsZero returns if the quiz is set or not.

func (Quiz) LatestResult

func (q Quiz) LatestResult() *QuizResult

LatestResult returns the latest result.

func (Quiz) PromptStats

func (q Quiz) PromptStats() (output []*PromptStats)

PromptStats returns stats for each prompt.

func (Quiz) Stats

func (q Quiz) Stats() (stats QuizStats)

Stats returns the stats for the quiz.

func (Quiz) TableName

func (q Quiz) TableName() string

TableName returns the database tablename for the type.

type QuizPrompt

type QuizPrompt struct {
	Quiz       Quiz
	CreatedUTC time.Time
	Prompt     string
	Expected   string
}

QuizPrompt is a specific quiz prompt.

type QuizResult

type QuizResult struct {
	ID          uuid.UUID `db:"id,pk"`
	QuizID      uuid.UUID `db:"quiz_id"`
	UserID      uuid.UUID `db:"user_id"`
	CreatedUTC  time.Time `db:"created_utc"`
	AnsweredUTC time.Time `db:"answered_utc"`
	Prompt      string    `db:"prompt"`
	Expected    string    `db:"expected"`
	Actual      string    `db:"actual"`
}

QuizResult is a quiz result.

func NewTestQuizResultCorrect

func NewTestQuizResultCorrect(quiz *Quiz) *QuizResult

NewTestQuizResultCorrect returns a new correct quiz result.

func NewTestQuizResultIncorrect

func NewTestQuizResultIncorrect(quiz *Quiz) *QuizResult

NewTestQuizResultIncorrect returns a new correct quiz result.

func (QuizResult) Correct

func (qr QuizResult) Correct() bool

Correct returns if the actual answer matches the expected.

It will trim space, and use a case insensitive equals.

func (QuizResult) Elapsed

func (qr QuizResult) Elapsed() time.Duration

Elapsed returns the elapsed time as a duration from the answered to the created times.

func (QuizResult) TableName

func (qr QuizResult) TableName() string

TableName returns the database tablename for the type.

type QuizStats

type QuizStats struct {
	Total          int
	Correct        int
	ElapsedAverage time.Duration
	ElapsedMin     time.Duration
	ElapsedMax     time.Duration
	ElapsedP75     time.Duration
	ElapsedP90     time.Duration
	ElapsedP95     time.Duration
}

QuizStats hold statistics for a quiz.

func (QuizStats) PercentCorrect

func (qs QuizStats) PercentCorrect() float64

PercentCorrect returns the percentage correct.

Jump to

Keyboard shortcuts

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