open-spaced-repetition / swift-fsrs

Swift Package for FSRS
MIT License
27 stars 14 forks source link

Add any usage documentation please #7

Closed keepfocused closed 9 months ago

keepfocused commented 9 months ago

Any usage documentation please ?

For example I have a card.

Then I trying to create let fsrs = FSRS()

Then I trying to use fsrs.repeat(card:card, Date.now()) as I seen it in different languages implementations but have no clue what and how to do next.

bensmiley commented 9 months ago

@keepfocused this is how I use it:

    public func review(rating: Rating? = nil, card: FSRSCard) -> FSRSCard {
        let fsrs = FSRS()
        let now = Date()

        let scheduling = fsrs.repeat(card: card, now: now)

        if let rating = rating, let next = scheduling[rating] {
            return next.card
        } else {
            return card
        }
    }

When this is a new card with no data, you call this with the rating set to nil. After that, you pass in the card and the rating and get back the card with updated stats.

keepfocused commented 9 months ago

@keepfocused this is how I use it:


When this is a new card with no data, you call this with the rating set to `nil`. After that, you pass in the card and the rating and get back the card with updated stats.

Thanks. And next question is how do I get to know when card is done ?

Which state indicates me what card is reached its maximum level and now I can exclude it as "mastered" ?

bensmiley commented 9 months ago

@keepfocused you may be better off asking this on the main project. I just ported this code, I didn't design it.

However, my guess would be that there isn't such as thing as "maximum level". This algorithm just predicts when the card needs to appear next. So naturally as you master a card, it will appear further and further in the future. If you wanted to make a cutoff at ~5 years say, you could do that.