pub fn review(&mut self, settings: &settings::TagSettings, score: Score, priority: Priority, familiarity: Ease, max_interval: chrono::Duration) {
        let now = now();
        // Add review to card history.
        self.history.push(Review {
            time: now,
            due: self.due,
            ended_interval: self.current_interval,
            score,
            state_before: self.state,
            ease_before: self.ease,
        });

        // Update the card state.
        match self.state {
            CardState::New => {
                // Update interval.
                self.current_interval = self.new_interval_new(settings, score, max_interval);
                self.due = now + self.current_interval;
                // Update state.
                self.state = CardState::Learning(0);
            },
            CardState::Learning(step) => {
                // Update interval.
                self.current_interval = self.new_interval_learning(settings, score, step, max_interval);
                self.due = now + self.current_interval;

                // TODO: Get rid of this spaghetti. This is already a done in
                //       `new_interval_learning`. For example, make `new_interval_learning` also
                //       return `new_step`.
                // Calculate new step.
                let new_step = settings.get_learning_interval(
                    step as isize + settings.learning_interval_progressions[score as usize]
                );

                // Update state.
                self.state = if new_step == settings.learning_intervals.len() - 1 {
                    CardState::Learnt
                } else {
                    CardState::Learning(new_step)
                };
            },
            CardState::Relearning(step) => {
                // TODO: Get rid of this spaghetti. This is already a done in
                //       `new_interval_relearning`. For example, make `new_interval_relearning` also
                //       return `new_step`.
                // Update interval.
                self.current_interval = self.new_interval_relearning(settings, score, step, max_interval);
                self.due = now + self.current_interval;

                // Calculate new step.
                let new_step = settings.get_relearning_interval(
                    step as isize + settings.relearning_interval_progressions[score as usize]
                );

                // Update state.
                self.state = if new_step == settings.relearning_intervals.len() - 1 {
                    CardState::Learnt
                } else {
                    CardState::Relearning(new_step)
                };
            },
            CardState::Learnt => {
                if score == Score::Fail {
                    // Update state if card failed.
                    self.state = CardState::Relearning(0);
                    // Update interval.
                    self.current_interval = settings.relearning_intervals[0];
                    self.due = now + self.current_interval;
                } else {
                    // Update interval.
                    self.current_interval = self.new_interval_learnt(settings, score, priority, familiarity, max_interval);
                    self.due = now + self.current_interval;
                }
                // Update ease.
                self.ease = self.new_ease(settings, score);
            },
        }
    }
/// Update the card after review.
Update the card after review.
Update the card after review .
pub fn review(&mut self, settings: &settings::TagSettings, score: Score, priority: Priority, familiarity: Ease, max_interval: chrono::Duration) {
        let now = now();
        // Add review to card history.
        self.history.push(Review {
            time: now,
            due: self.due,
            ended_interval: self.current_interval,
            score,
            state_before: self.state,
            ease_before: self.ease,
        });
        // Update the card state.
        match self.state {
            CardState::New => {
                // Update interval.
                self.current_interval = self.new_interval_new(settings, score, max_interval);
                self.due = now + self.current_interval;
                // Update state.
                self.state = CardState::Learning(0);
            },
            CardState::Learning(step) => {
                // Update interval.
                self.current_interval = self.new_interval_learning(settings, score, step, max_interval);
                self.due = now + self.current_interval;
                // TODO: Get rid of this spaghetti. This is already a done in
                //       `new_interval_learning`. For example, make `new_interval_learning` also
                //       return `new_step`.
                // Calculate new step.
                let new_step = settings.get_learning_interval(
                    step as isize + settings.learning_interval_progressions[score as usize]
                );
                // Update state.
                self.state = if new_step == settings.learning_intervals.len() - 1 {
                    CardState::Learnt
                } else {
                    CardState::Learning(new_step)
                };
            },
            CardState::Relearning(step) => {
                // TODO: Get rid of this spaghetti. This is already a done in
                //       `new_interval_relearning`. For example, make `new_interval_relearning` also
                //       return `new_step`.
                // Update interval.
                self.current_interval = self.new_interval_relearning(settings, score, step, max_interval);
                self.due = now + self.current_interval;
                // Calculate new step.
                let new_step = settings.get_relearning_interval(
                    step as isize + settings.relearning_interval_progressions[score as usize]
                );
                // Update state.
                self.state = if new_step == settings.relearning_intervals.len() - 1 {
                    CardState::Learnt
                } else {
                    CardState::Relearning(new_step)
                };
            },
            CardState::Learnt => {
                if score == Score::Fail {
                    // Update state if card failed.
                    self.state = CardState::Relearning(0);
                    // Update interval.
                    self.current_interval = settings.relearning_intervals[0];
                    self.due = now + self.current_interval;
                } else {
                    // Update interval.
                    self.current_interval = self.new_interval_learnt(settings, score, priority, familiarity, max_interval);
                    self.due = now + self.current_interval;
                }
                // Update ease.
                self.ease = self.new_ease(settings, score);
            },
        }
    }
pub fn review ( & mut self , settings : & settings :: TagSettings , score : Score , priority : Priority , familiarity : Ease , max_interval : chrono :: Duration ) { let now = now ( ) ; // Add review to card history. self . history . push ( Review { time : now , due : self . due , ended_interval : self . current_interval , score , state_before : self . state , ease_before : self . ease , } ) ; // Update the card state. match self . state { CardState :: New => { // Update interval. self . current_interval = self . new_interval_new ( settings , score , max_interval ) ; self . due = now + self . current_interval ; // Update state. self . state = CardState :: Learning ( 0 ) ; } , CardState :: Learning ( step ) => { // Update interval. self . current_interval = self . new_interval_learning ( settings , score , step , max_interval ) ; self . due = now + self . current_interval ; // TODO: Get rid of this spaghetti. This is already a done in //       `new_interval_learning`. For example, make `new_interval_learning` also //       return `new_step`. // Calculate new step. let new_step = settings . get_learning_interval ( step as isize + settings . learning_interval_progressions [ score as usize ] ) ; // Update state. self . state = if new_step == settings . learning_intervals . len ( ) - 1 { CardState :: Learnt } else { CardState :: Learning ( new_step ) } ; } , CardState :: Relearning ( step ) => { // TODO: Get rid of this spaghetti. This is already a done in //       `new_interval_relearning`. For example, make `new_interval_relearning` also //       return `new_step`. // Update interval. self . current_interval = self . new_interval_relearning ( settings , score , step , max_interval ) ; self . due = now + self . current_interval ; // Calculate new step. let new_step = settings . get_relearning_interval ( step as isize + settings . relearning_interval_progressions [ score as usize ] ) ; // Update state. self . state = if new_step == settings . relearning_intervals . len ( ) - 1 { CardState :: Learnt } else { CardState :: Relearning ( new_step ) } ; } , CardState :: Learnt => { if score == Score :: Fail { // Update state if card failed. self . state = CardState :: Relearning ( 0 ) ; // Update interval. self . current_interval = settings . relearning_intervals [ 0 ] ; self . due = now + self . current_interval ; } else { // Update interval. self . current_interval = self . new_interval_learnt ( settings , score , priority , familiarity , max_interval ) ; self . due = now + self . current_interval ; } // Update ease. self . ease = self . new_ease ( settings , score ) ; } , } }
Update the card after review.
Update the card after review .
&mut self
settings
&settings::TagSettings
score
Score
priority
Priority
familiarity
Ease
max_interval
chrono::Duration
&mut self
settings
&settings::TagSettings
score
Score
priority
Priority
familiarity
Ease
max_interval
chrono::Duration