def next_repetition_per_grade(self, reviewed_at=None): #FIXME disable fuzzing if not reviewed_at: reviewed_at = datetime.utcnow() reps = {} for grade in ALL_GRADES: repetition_algo = repetition_algo_dispatcher( self, grade, reviewed_at=reviewed_at) reps[grade] = repetition_algo.next_repetition() return reps
def review(self, grade, duration=None, question_duration=None): ''' Commits a review rated with `grade`. `question_duration` is an optional parameter which contains the time (in seconds, floating point) that the user spent looking at the question/front side of the card, before hitting "Show Answer" to see the back. It is in effect the time spent thinking of the answer. `duration` is the same, but for each entire duration of viewing this card (so, the time taken for the front and back of the card.) ''' from manabi.apps.flashcards.signals import pre_card_reviewed, post_card_reviewed pre_card_reviewed.send(self, instance=self) reviewed_at = datetime.utcnow() was_new = self.is_new # Update this card's statistics card_history_item = self._update_statistics( grade, reviewed_at, duration=duration, question_duration=question_duration) # Create Undo stack item UndoCardReview.objects.add_undo(card_history_item) # Compute and apply updated card repetition values. repetition_algo = repetition_algo_dispatcher(self, grade, reviewed_at=reviewed_at) repetition_algo.next_repetition.delete_cache(repetition_algo) next_repetition = repetition_algo.next_repetition() self._apply_updated_schedule(next_repetition) self.last_review_grade = grade self.last_reviewed_at = reviewed_at if grade == GRADE_NONE: self.last_failed_at = reviewed_at # Finish up the card history item record card_history_item.ease_factor = self.ease_factor card_history_item.interval = self.interval card_history_item.save() self.save() # self.redis.after_review() post_card_reviewed.send(self, instance=self)
def review(self, grade, duration=None, question_duration=None): ''' Commits a review rated with `grade`. `question_duration` is an optional parameter which contains the time (in seconds, floating point) that the user spent looking at the question/front side of the card, before hitting "Show Answer" to see the back. It is in effect the time spent thinking of the answer. `duration` is the same, but for each entire duration of viewing this card (so, the time taken for the front and back of the card.) ''' from manabi.apps.flashcards.signals import pre_card_reviewed, post_card_reviewed pre_card_reviewed.send(self, instance=self) reviewed_at = datetime.utcnow() was_new = self.is_new # Update this card's statistics card_history_item = self._update_statistics( grade, reviewed_at, duration=duration, question_duration=question_duration) # Create Undo stack item UndoCardReview.objects.add_undo(card_history_item) # Compute and apply updated card repetition values. repetition_algo = repetition_algo_dispatcher( self, grade, reviewed_at=reviewed_at) repetition_algo.next_repetition.delete_cache(repetition_algo) next_repetition = repetition_algo.next_repetition() self._apply_updated_schedule(next_repetition) self.last_review_grade = grade self.last_reviewed_at = reviewed_at if grade == GRADE_NONE: self.last_failed_at = reviewed_at # Finish up the card history item record card_history_item.ease_factor = self.ease_factor card_history_item.interval = self.interval card_history_item.save() self.save() # self.redis.after_review() post_card_reviewed.send(self, instance=self)