Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDeckNotFound = errors.New("deck not found")
var ErrEmptyReview = errors.New("no cards in queue")
ErrEmptyReview indicates the review session has not more cards left to review.
var ErrInvalidScore = errors.New("invalid score")
ErrInvalidScore is returned by NewReviewScore when the given string is not a number of is out of the valid range.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct { ID string `json:"id" validate:"required"` Question string `json:"question" validate:"required"` Answer string `json:"answer" validate:"required"` ReviewedAt time.Time `json:"reviewed_at" validate:"required"` EasinessFactor float64 `json:"easiness_factor" validate:"required"` Interval float64 `json:"interval" validate:"required"` Repetitions int `json:"repetitions" validate:"required"` Stats []Stats `json:"stats"` }
Card represents a single card in a Deck.
func (Card) Advance ¶
func (c Card) Advance(ts time.Time, score ReviewScore) Card
Advance advances supermemo state for a card.
func (Card) NextReviewAt ¶
NextReviewAt returns next review timestamp for a card.
type Deck ¶
type Deck struct { Name string `json:"name" validate:"required"` Cards []Card `json:"cards"` ID string // contains filtered or unexported fields }
Deck represents a named collection of cards.
func (Deck) HasDueCards ¶
HasDueCards says if the deck has due cards.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository defines storage interface that manages a set of decks.
func NewRepository ¶
func NewRepository(path string, clock clock.Clock) (*Repository, error)
NewRepository create a new deck repository by reading all decks from a given folder.
func (*Repository) Create ¶
func (r *Repository) Create(name string, cards []Card) (Deck, error)
Create creates a new deck from a given name.
func (*Repository) Delete ¶
func (r *Repository) Delete(deck Deck) error
Delete removes the deck from the repository.
type Review ¶
Review represents a review session.
func NewReview ¶
NewReview returns a new Review from a given a deck. It gets the due cards from the deck a shuffle them.
func (Review) Rate ¶
func (r Review) Rate(score ReviewScore) (Review, error)
Rate scores the current card.
type ReviewScore ¶
type ReviewScore int
ReviewScore defines grade for review attempts. Review uses scores to calculate rating in range from [0, 4] inclusive.
const ( ReviewScoreAgain ReviewScore = iota ReviewScoreHard ReviewScoreNormal ReviewScoreEasy ReviewScoreSuperEasy // InitialEasinessFactor defines the initial easiness factor. InitialEasinessFactor = 2.5 // MinEasinessFactor defines the minimal easiness factor possible. MinEasinessFactor = 1.3 )
func NewReviewScore ¶
func NewReviewScore(s string) (ReviewScore, error)
NewReviewScore converts a string to a ReviewScore.
func (ReviewScore) String ¶
func (s ReviewScore) String() string
type Stats ¶
type Stats struct { Algorithm string `json:"algorithm" validate:"required"` Timestamp time.Time `json:"timestamp" validate:"required"` Score ReviewScore `json:"score" validate:"required"` LastReview time.Time `json:"last_review" validate:"required"` Repetitions int `json:"repetitions" validate:"required"` Interval float64 `json:"interval" validate:"required"` EasinessFactor float64 `json:"easiness_factor" validate:"required"` }
Stats is the revised card statistics.