private void SubmitAnswer_Click(object sender, RoutedEventArgs e) { ExControl.NextExerciseVisible(); List<bool> choiceList = parseToList(MultipleChoiceAnswerInput.SelectedItems); MultipleChoiceAnswerInput.SelectedItems.Clear(); if (choiceList.Count == 0) return; AnswerList<bool> ans = new AnswerList<bool>(choiceList); bool correctAnswer = true; bool[] feedback = ans.GetFeedback(App.ViewModel.CurrentSolution.Answer as AnswerList<bool>); StringBuilder headerBuilder = new StringBuilder(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < feedback.Length; ++i) { if (!feedback[i]) { correctAnswer = false; break; } } var currentExerciseId = App.ViewModel.Exercises[App.ViewModel.CurrentQuestionNumber].ID; if (correctAnswer) { App.ViewModel.AddAnswer(currentExerciseId, true); App.ViewModel.CorrectAnswers++; App.ViewModel.AddAnswer(true); headerBuilder.Append("Correct!"); builder.Append(""); ExControl.CorrectAnswerMediaElement.Play(); } else { App.ViewModel.AddAnswer(currentExerciseId, false); App.ViewModel.AddAnswer(false); headerBuilder.Append("You're wrong :-("); builder.Append("Explanation:\n"); for (int i = 0; i < feedback.Length; ++i) { builder.Append(i + 1); if (feedback[i]) { builder.Append("). OK\n"); } else { builder.Append("). Wrong!"); builder.AppendLine(); } } ExControl.WrongAnswerMediaElement.Play(); } MultipleChoiceAnswerInput.Visibility = Visibility.Collapsed; ExControl.SubmitAnswerClick(headerBuilder, builder); }