Esempio n. 1
0
        /// <summary>
        /// Обработка ответа пользователя.
        /// </summary>
        /// <param name="id">Идентификатор пользователя.</param>
        /// <param name="user">Имя пользователя.</param>
        /// <param name="answer">Ответ пользователя.</param>
        private async Task ProcessAnswer(int id, string user, string answer)
        {
            var isAnswerCorrect = _tasksProcessing.IsAnswerCorrect(_subStates[id].TasksInfos[_subStates[id].CurrentTaskNum], AnswerCommands.IndexOf(answer));

            _subStates[id].Results.Add(isAnswerCorrect);
            var message = isAnswerCorrect
                ? "Верно!\n\r"
                : string.Format(@"Неверно!{0}Объяснение: {0}{1}{0}", Environment.NewLine,
                                _subStates[id].TasksInfos[_subStates[id].CurrentTaskNum].Explanation);

            await _telegramBotClient.SendTextMessageAsync(id, message).ConfigureAwait(false);

            if (_subStates[id].CurrentTaskNum + 1 == _subStates[id].TasksInfos.Count)
            {
                await SaveStatistic(id, user).ConfigureAwait(false);
                await SendResult(id).ConfigureAwait(false);

                await _testStateController.ResetState(id).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
 public void CheckTextAnswerTest()
 {
     Assert.That(_tasksProcessing.IsAnswerCorrect(Task, First), Is.False);
     Assert.That(_tasksProcessing.IsAnswerCorrect(Task, Second), Is.True);
     Assert.That(_tasksProcessing.IsAnswerCorrect(Task, Third), Is.False);
 }