views:

96

answers:

2

A client has asked me to add a simple spaced repeition algorithm (SRS) for an onlinebased learning site. But before throwing my self into it, I'd like to discuss it with the community.

Basically the site asks the user a bunch of questions (by automatically selecting say 10 out of 100 total questions from a database), and the user gives either a correct or incorrect answer. The users result are then stored in a database, for instance:

userid  questionid  correctlyanswered  dateanswered
1       123         0 (no)             2010-01-01 10:00
1       124         1 (yes)            2010-01-01 11:00
1       125         1 (yes)            2010-01-01 12:00    

Now, to maximize a users ability to learn all answers, I should be able to apply an SRS algorithm so that a user, next time he takes the quiz, receives questions incorrectly answered more often; than questions answered correctly. Also, questions that are previously answered incorrectly, but recently often answered correctly should occur less often.

Have anyone implemented something like this before? Any tips or suggestions?

Theese are the best links I've found:

+1  A: 

Anki is an open source program implementing spaced repetition. Being open source, you can browse the source for libanki, a spaced repetition library for Anki.

The sources are in Python, the executable pseudo code language. Reading the source to understand the algorithm may be feasible. The data model is defined using sqlalechmey, the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

gimel
+1  A: 

What you want to do is to have a number X_i for all questions i. You can normalize these numbers (make their sum 1) and do a priotized choice.

If N is the number of different questions and M is the number of times each question has been answered in average, then you could find X in M*N time like this:

  • Create the array X[N] set to 0.
  • Run through the data, and every time you see question i answered wrong, increse N[i] by f(t) where t is the answereing time and f is an incresing function.

Because f is incresing, a question answered wrong a long time ago has less impact than one answered wrong yesterday. You can experiment with different f to get a nice behavior.

The smarter way A faster way is not to generate X[] everytime you choose questions, but save it in a database table. You wont be able to apply f with this solution. Instead just add 1 everytime the question is answered wrongly, and then run through the table regularily - say every midnight - and multiply all X[i] by a constant - say 0.9.

Update: Actually you should base your data on corrects, not wrongs. Otherwise questions not answered neither true nor false for a long time, will have a smaller chance of getting chosen. It should be opposite.

Thomas Ahle