Okubo is a simple spaced-repetition system which you can associate with Active Record models to be learned (such as words in a foreign language) and users in your system. Users study these words, and as they mark these attempts right or wrong, Okubo will determine when they should be reviewed next.
Okubo determines the next study time for an item using the Leitner System. In the future it may support other popular algorithms, such as the Supermemo 2 algorithm.
Add to Gemfile (will put on rubygems once at 0.1):
gem 'okubo', :git => "git://github.com/rgravina/okubo.git"
bundle install rails generate okubo rake db:migrate
Assume you have an application allowing your users to study words in a foreign language. Using the
you can set up a deck of flashcards that the user will study:
class Word < ActiveRecord::Base end class User < ActiveRecord::Base has_deck :words end user = User.create!(:name => "Robert") word = Word.create!(:kanji => "日本語", :kana => "にほんご", :translation => "Japanese language")
You can add words and record attempts to guess the word as right or wrong. Various methods exist to allow you to access subsets of this collection:
# Initally adding a word user.words << word user.words.untested #=> [word] # Guessing a word correctly user.right_answer_for!(word) user.words.known #=> [word] # Guessing a word incorrectly user.wrong_answer_for!(word) user.words.failed #=> [word] # Listing all words user.words #=> [word]
As time passes words need to be reviewed to keep them fresh in memory:
# Three days later... user.words.known #=>  user.words.expired #=> [word]
Guessing a word correcly several times in a row results in the word taking longer to expire, and demonstrates mastery of that word.
user.right_answer_for!(word) # One week later... user.words.expired #=> [word] user.right_answer_for!(word) # Two weeks later... user.words.expired #=> [word] user.right_answer_for!(word) # One month later... user.words.expired #=> [word]
In addition to an
expired method, Okubo provides a suggested reviewing sequence for all unknown words in the deck.
Words are randomly chosen from all untested words, failed, and finally expired in order of precedence.
user.words.review #=> [word] user.right_answer_for!(word) # ... continuing until all untested, failed, and expired words have been guessed correctly. user.words.review #=> 
You can also just get the next word to review:
user.words.next #=> word user.right_answer_for!(word) # ... continuing until all untested, failed, and expired words have been guessed correctly. user.words.next #=> nil
- activerecord-reputation-system - for providing the design and implementation from which this gem is based.
- randym - for enouraging me work on this gem in the first place.
- Tokyo Rails - for providing collaboration evenings where this gem was worked on.
- Reviewing the Kanji - for providing a great visual representation and implementation of the Leitner system.
Copyright and License
Okubo © 2012 by Robert Gravina. Okubo is licensed under the MIT license. Please see the LICENSE document for more information.