public static void UpdateVocabulary(UserProfile userProfile, List<VocabEntryHandle> entries, VocabRankTypes rankType, AnswerScore score = AnswerScore.Unknown) { foreach (var entry in entries) { UpdateVocabulary(userProfile, entry, rankType, score); } }
public static void UpdateVerbConjugationHistoryFromSentence(UserProfile profile, Sentence sentence, AnswerScore score) { var verbConjugations = sentence.RoleConjugationPairs.Where(qt => qt.Item2.GetType() == typeof(VerbConjugation)).Select(qt => qt.Item2 as VerbConjugation); foreach (var vc in verbConjugations) { UpdateVerbConjugationHistory(profile, vc, score); } }
public static void UpdateVerbConjugationHistory(UserProfile profile, VerbConjugation conj, AnswerScore score) { var vchi = profile.History.VerbConjugationHistory.Find(v => v.VerbConjugation.Equals(conj)); if (vchi == null) { vchi = new VerbConjugationHistoryItem() { VerbConjugation = conj }; profile.History.VerbConjugationHistory.Insert(0, vchi); } HistoryItemOperations.UpdateHistoryItemWithSuccessFailureAndTimestamp(vchi, score); }
public static void UpdateNounConjugationHistory(UserProfile profile, NounConjugation conj, AnswerScore score) { var nchi = profile.History.NounConjugationHistory.Find(n => n.NounConjugation.Equals(conj)); if (nchi == null) { nchi = new NounConjugationHistoryItem() { NounConjugation = conj }; profile.History.NounConjugationHistory.Insert(0, nchi); } HistoryItemOperations.UpdateHistoryItemWithSuccessFailureAndTimestamp(nchi, score); }
public static void UpdateVocabulary(UserProfile userProfile, VocabEntryHandle entry, VocabRankTypes rankType, AnswerScore score = AnswerScore.Unknown) { VocabularyHistoryItem vhi = userProfile.History.VocabHistory.Find(h => h.VocabEntry.Equals(entry)); if (vhi == null) { vhi = new VocabularyHistoryItem() { Rank = rankType, VocabEntry = entry }; userProfile.History.VocabHistory.Insert(0, vhi); } HistoryItemOperations.UpdateHistoryItemWithSuccessFailureAndTimestamp(vhi, score); }
public static void UpdateHistoryItemWithSuccessFailureAndTimestamp(HistoryItem historyItem, AnswerScore score) { historyItem.LastTimestamp = DateTime.UtcNow; if (score == AnswerScore.Right) { historyItem.SuccessCount++; } if (score == AnswerScore.Wrong) { historyItem.FailureCount++; } }
// Make a UserProfileManager and move this there along with other update functionality related to the user. public static void UpdateUserProfileWithCurrentSentenceResponse(UserProfile profile, AnswerDimension answerDimension, AnswerScore score) { var topicStateMachineState = profile.CurrentState.CourseLocationInfo.TopicLocationInfo; var sampleSectionState = topicStateMachineState.ExerciseSectionState; var currentSentence = Repositories.Repositories.Sentences.GetItemByHandle(sampleSectionState.CurrentSentence); var currentSentenceHistoryItem = profile.History.SentenceHistory.Find(shi => shi.Sentence.Equals(sampleSectionState.CurrentSentence)); if (currentSentenceHistoryItem == null) { currentSentenceHistoryItem = new SentenceHistoryItem() { Sentence = sampleSectionState.CurrentSentence }; profile.History.SentenceHistory.Insert(0, currentSentenceHistoryItem); } // TODO: Potential pitfall to investigate. // First question always re-uses the existing sentence. This will lead to double updates. HistoryItemOperations.UpdateHistoryItemWithSuccessFailureAndTimestamp(currentSentenceHistoryItem, score); VocabOperations.UpdateVocabulary(profile, currentSentence.VocabEntries, VocabRankTypes.SeenInSampleOrQuestion, score); NounConjugationOperations.UpdateNounConjugationHistoryFromSentence(profile, currentSentence, score); VerbConjugationOperations.UpdateVerbConjugationHistoryFromSentence(profile, currentSentence, score); if (NounConjugationPolicies.CanMoveToNextNounConjugation(profile)) { profile.CurrentState.CurrentNounConjugationRank++; } foreach (var tense in profile.CurrentState.CurrentVerbConjugationRanksByTense.Keys) { if (VerbConjugationPolicies.CanMoveToNextVerbConjugation(profile, tense)) { profile.CurrentState.CurrentVerbConjugationRanksByTense[tense]++; } } if (profile.CurrentState.CourseLocationInfo.TopicLocationInfo.ExerciseSectionState.IsQuestion) { TopicOperations.UpdateAnswerDimensionCounts(profile, answerDimension, score); if (sampleSectionState.CurrentQuestionDimension == QuestionDimension.Grammar) { LearningTypeOperations.UpdateLearningTypeScore(profile, score); } } }