mirror of
https://github.com/ankitects/anki.git
synced 2026-01-19 00:39:00 -05:00
+ zero remaining steps when graduating (they shouldn't have been doing any harm, but this is neater) + add some more tests that cover these cases
43 lines
1.4 KiB
Rust
43 lines
1.4 KiB
Rust
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
use super::{CardStateUpdater, RevlogEntryPartial};
|
|
use crate::{
|
|
card::{CardQueue, CardType},
|
|
scheduler::states::{CardState, IntervalKind, RelearnState},
|
|
};
|
|
|
|
impl CardStateUpdater {
|
|
pub(super) fn apply_relearning_state(
|
|
&mut self,
|
|
current: CardState,
|
|
next: RelearnState,
|
|
) -> Option<RevlogEntryPartial> {
|
|
self.card.interval = next.review.scheduled_days;
|
|
self.card.remaining_steps = next.learning.remaining_steps;
|
|
self.card.ctype = CardType::Relearn;
|
|
self.card.lapses = next.review.lapses;
|
|
self.card.ease_factor = (next.review.ease_factor * 1000.0).round() as u16;
|
|
|
|
let interval = next
|
|
.interval_kind()
|
|
.maybe_as_days(self.secs_until_rollover());
|
|
match interval {
|
|
IntervalKind::InSecs(secs) => {
|
|
self.card.queue = CardQueue::Learn;
|
|
self.card.due = self.fuzzed_next_learning_timestamp(secs);
|
|
}
|
|
IntervalKind::InDays(days) => {
|
|
self.card.queue = CardQueue::DayLearn;
|
|
self.card.due = (self.timing.days_elapsed + days) as i32;
|
|
}
|
|
}
|
|
|
|
RevlogEntryPartial::maybe_new(
|
|
current,
|
|
next.into(),
|
|
next.review.ease_factor,
|
|
self.secs_until_rollover(),
|
|
)
|
|
}
|
|
}
|