Francesco Gallarotti bio photo

Francesco Gallarotti

I'm just another software engineer from Italy. I studied/worked/lived in New York state since 2000 to 2011, when I moved back to Italy. I love my wife, my three English Cocker Spaniels, landscape and portrait photography and simmering spicy curries. I have started learning Japanese numerous times.

Twitter LinkedIn Github Stackoverflow

Sebastian Leitner, a German psychologist presented in the early 70's a learning system that makes selective learning possible with less effort than the traditional method of studying a set of flashcards sequentially.

This is just a note to myself on how to implement the Lietner System.

First, this is the pseudocode for the main loop to review everything that needs to be reviewed:

foreach(Deck in User.Decks) {
    foreach(Card in Deck.Cards) {
        if((time.Now()-Card.LastReview) > Deck.TimeToReview {
            Card.Review();
        }
    }
}

Next is the single card review method:

if(review result is correct) {
    // if the card is in the last deck, increase the card memorization
    // level by one and put it back in deck 1 
    if(Card.Deck.Index = Decks.LastDeckIndex) {
        Card.Level++
        if(Card.Level < Card.Deck.MaxLevel) {
            // restart from deck 1 for next level review
            Card.Deck.Index = 1
        }
        else {
            // card has been memorized successfully 
            // remove card from deck 
        }
    }
    else {
        card.Deck.Index++
    }
}
else {
    card.Deck.Index = 1
    card.Level = 0
}