public double AcceptAnswer(TrainingCard trainingFlashcard, FlashcardAnswer answer) { var correctness = CalculateCorrectnessOfAnswer(answer); unit.UserFlashcardMemoryRepository.AddBasedOnTraining(trainingFlashcard, (decimal)(correctness * correctness)); unit.TrainingCardRepository.Remove(trainingFlashcard); unit.SaveChanges(); sessionService.UserInfo.TrainingInfo.Cards.RemoveAt(0); return(correctness); }
public bool AddNewReviewCardIfAble() { if (sessionService.UserInfo.ReviewInfo.ReviewCards.Count >= 30) { return(false); } var memory = unit.UserFlashcardMemoryRepository.GetFirstTrainableMemories(sessionService.UserID, sessionService.LanguageID, 1).FirstOrDefault(); if (memory == null) { return(false); } var reviewCard = unit.ReviewCardRepository.AddCardBasedOnMemory(memory, sessionService.UserInfo.ReviewInfo.ReviewID); unit.SaveChanges(); sessionService.UserInfo.ReviewInfo.AddCard(new DbReviewCard(reviewCard)); return(true); }
public double UpdateMemoryBasedOnAnswer(ReviewCard card, FlashcardAnswer answer) { var memory = unit.UserFlashcardMemoryRepository .GetMemoryBasedOnReview(card.ReviewID, card.FlashcardID, sessionService.UserID); var correctness = questionService.CalculateCorrectnessOfAnswer(answer); double newStrength = calculateNewStrength(card, memory, correctness); int newInterval = calculateNewInterval(memory, newStrength, card); memory.Strength = (decimal)newStrength; memory.LastInterval = newInterval; memory.IntervalCount++; memory.ReviewDate = DateTime.Now.AddMinutes(newInterval); unit.SaveChanges(); return(correctness); }