示例#1
0
        private void ConfirmAnswer()
        {
            var history = _wordUserHistories.FirstOrDefault(x => x.Language == SelectedDictionaryQuestion.Language &&
                                                            x.Word == CurrentQuestionWord.Text && x.UserId == _currentUser.Id);

            if (history == null)
            {
                history                  = _dao.CreateWordUserHistory();
                history.Language         = SelectedDictionaryQuestion.Language;
                history.Word             = CurrentQuestionWord.Text;
                history.UserId           = _currentUser.Id;
                history.TimesEncountered = 0;
                history.TimesRight       = 0;
            }
            if (_correctAnswers.Contains(SelectedAnswerWord))
            {
                CorrectAnswers      = _answeredCorrectly + 1;
                AnswerResultMessage = "Correct!\n";
                history.TimesRight++;
            }
            else
            {
                AnswerResultMessage = "Wrong!\n";
                foreach (var word in _correctAnswers)
                {
                    if (CurrentAnswerWords.Contains(word))
                    {
                        AnswerResultMessage += "Correct answer: '" + word.Text + "'.\n";
                        break;
                    }
                }
            }
            if (_currentQuestionSet.Count == 0)
            {
                AnswerResultMessage += "No more questions!";
            }
            Tries = _tries + 1;
            history.TimesEncountered++;
            _dao.SaveWordUserHistory(history);
            _answeredThisQuestion = true;
        }