/// <summary> /// Submits the current answer. /// </summary> private void SubmitAnswer() { if (string.IsNullOrEmpty(CurrentAnswer) || CurrentQuestion == null) { // Do not evaluate an empty answer. return; } // Convert the answer to kana if necessary. if (CurrentQuestion.Question == SrsQuestionEnum.Reading) { CurrentAnswer = KanaHelper.RomajiToKana(CurrentAnswer); } // Determine if the answer is correct. bool success = IsAnswerCorrect(); // Set the review state accordingly. // Other operations will be executed when we move on to another question. ReviewState = success ? SrsReviewStateEnum.Success : SrsReviewStateEnum.Failure; // Play audio if auto play enabled. if (CurrentQuestion.Question == SrsQuestionEnum.Reading && CurrentQuestionGroup.IsVocab && ((success && Properties.Settings.Default.AudioAutoplayMode.ShouldPlayOnSuccess()) || (!success && Properties.Settings.Default.AudioAutoplayMode.ShouldPlayOnFailure()))) { AudioBusiness.PlayVocabAudio(CurrentQuestionGroup.Audio); } // If we have a failure: trigger the timer. if (ReviewState == SrsReviewStateEnum.Failure) { _canSubmit = false; DispatcherTimer timer = new DispatcherTimer(); timer.Interval = FailureSubmitDelay; timer.Tick += OnFailureSubmitTimerTick; timer.Start(); } // If it was a success on the last question of the group, allow level up/down preview. else if (CurrentQuestionGroup.GetUnansweredQuestions().Count() == 1) { SrsLevelStore.Instance.IssueWhenLoaded( () => { DispatcherHelper.Invoke(() => { PreviewNextLevel = GetUpdatedLevel(CurrentQuestionGroup); }); }); } }
/// <summary> /// Command callback. /// Called to play the audio of the given vocab. /// </summary> /// <param name="vocab">Vocab to play.</param> private void OnPlayAudio(ExtendedVocab vocab) { AudioBusiness.PlayVocabAudio(vocab.Audio); }