Documentation

Overview

    A model for spaced repetition system learning.

    This package maintains a database of problems, and some notions of intervals and a bit of history in order to allow them to be used for spaced repetition learning.

    The key type is the `T` which is associated with a single database file.

    A given `Problem` is simply two text strings, a question and an answer. It is up to the user of this package to determine what these mean. It could be as simple as text to display to the user, or some encoded data to determine the correct answer.

    The client of this package should be able to ask questions, determine if the answer is correct, and return a 1-4 rating of how well the user answered the question. In some cases, it may only make sense to return either a 1 for an incorrect answer, or a 4 for a correct answer.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Bucket

    type Bucket struct {
    	Name  string // Short description of this bucket.
    	Count int    // The number of problems in this bucket.
    }

      A Bucket is a single histogram bucket describing the number of problems of a given category.

      type Counts

      type Counts struct {
      	// The number of "Active" problems.  Something is considered
      	// active if it is due for learning.
      	Active int
      
      	// The number of problems that are being learned, but aren't
      	// ready to be asked again.
      	Later int
      
      	// The number of problems the user has never been shown
      	Unlearned int
      
      	// Counts of all of the problems, groups into histogram
      	// buckets based on the learning interval of the problem. The
      	// bucket names are a short description of the interval
      	Buckets []Bucket
      }

        Counts contains statistics about the current state of problems.

        type Populator

        type Populator struct {
        	// contains filtered or unexported fields
        }

          A Populator wraps a database transaction to be able to populate a database with problems to learn. The database should not otherwise be used while this is opened.

          func (Populator) Add

          func (p Populator) Add(question, answer string) error

            Add adds a single unlearned problem to the given store.

            func (Populator) Commit

            func (p Populator) Commit() error

              Commit finishes adding problems to the store, by committing the database transaction.

              func (Populator) Rollback

              func (p Populator) Rollback() error

                Rollback the transaction.

                func (Populator) Wipe

                func (p Populator) Wipe() error

                  Wipe all of the problems. This is generally done in preparation to replace all of the questions. We assume that the sequence numbers will start over again at 1.

                  type Problem

                  type Problem struct {
                  	Question string        // The question to be asked.
                  	Answer   string        // The correct answer.
                  	Next     time.Time     // When to next ask this question.
                  	Interval time.Duration // Current interval to next question
                  	// contains filtered or unexported fields
                  }

                    A problem is a single problem retrieved.

                    type T

                    type T struct {
                    	// contains filtered or unexported fields
                    }

                    func Create

                    func Create(path, kind string) (*T, error)

                      Create creates a new store at the given path. Will return an error if the database has already been created. The `kind` is a string that can be used later to determine what kind of user interaction to use (and that defines the interpretation of the problems).

                      func Open

                      func Open(path string) (*T, error)

                        Open an existing database.

                        func (*T) Begin

                        func (t *T) Begin() (Populator, error)

                        func (*T) Close

                        func (t *T) Close() error

                        func (*T) GetCounts

                        func (t *T) GetCounts() (*Counts, error)

                          GetCounts retrieves statistics about the problems available.

                          func (*T) GetNew

                          func (t *T) GetNew() (*Problem, error)

                            Get a problem that hasn't started being learned. The interval and next will be set appropriately for a new problem. If there are no new problems, the result will be (nil, nil). TODO: Set the interval based on a configurable value, as the default depends on the problem types.

                            func (*T) GetNexts

                            func (t *T) GetNexts(count int) ([]*Problem, error)

                              GetNexts queries for `count` upcoming problems that are ready to be asked. Will return an array of problems, with element 0 being the next problem that should be asked.

                              func (*T) Kind

                              func (t *T) Kind() string

                              func (*T) TestSetNowFunc

                              func (t *T) TestSetNowFunc(now func() time.Time)

                                For debug and testing, override the query for the current time with something that is configurable.

                                func (*T) Update

                                func (t *T) Update(prob *Problem, factor int) error

                                  Update updates a problem, based on a learning factor. The scale is 1-4, with 1 being totally incorrect, and 4 being totally correct.