/// <summary> /// Дать ответ /// </summary> /// <param name="answer">Ответ</param> public void TakeAnswer(int answer, bool onTimeEnded = false) { currentExample.UserAnswer = answer; // Устанавливам State: currentExample.SetState(answer == currentExample.UserAnswer ? ExampleState.RightAnswered : ExampleState.WrongAnswered); if (onTimeEnded) { currentExample.SetState(ExampleState.NotAnswered); } processedExample.Add(currentExample); if (exampleSet.Count > 0) { currentExample = exampleSet.Dequeue(); TakeNextExample?.Invoke(this, new ExampleParameters(currentExample.OperandOne, currentExample.OperandTwo, currentExample.Opr)); timer.Stop(); Tick?.Invoke(this, timeToExample); remainingTime = timeToExample; timer.Start(); } else { timer.Stop(); IsStarted = false; TrainingEnded?.Invoke(this, DateTime.Now); } }
/// <summary> /// Запуск теста /// </summary> public void StartTraining() { //Если тест ещё не запущен, то запускаем. Иначе ничего не делаем if (!IsStarted) { IsStarted = true; currentExample = exampleSet.Dequeue(); TrainingStarted?.Invoke(this, DateTime.Now); TakeNextExample?.Invoke(this, new ExampleParameters(currentExample.OperandOne, currentExample.OperandTwo, currentExample.Opr)); timer.AutoReset = true; timer.Start(); timer.Elapsed += Timer_Elapsed; remainingTime = timeToExample; Tick?.Invoke(this, timeToExample); } }