public void UpdateQuestions()
        {
            QuestionsStackPanel.Children.Clear();

            foreach (var wrongQuestionID in QuestionManager.WrongAnsweredQuestions)
            {
                QuestionsStackPanel.Children.Add(new CheckQuestionItem(QuestionManager.GetWrongQuestion(wrongQuestionID.ID),
                                                                       QuestionManager.GetQuestion(wrongQuestionID.ID)));
            }
        }
Beispiel #2
0
        private void CheckAnswersButton_Click(object sender, RoutedEventArgs e)
        {
            var question          = new Question(actualQuestionNumber, QuestionTextBlock.Text);
            int pickedGoodAnswers = 0;
            int goodAnswers       = 0;
            int picks             = 0;

            foreach (AnswerContent answerContent in AnswersStackPanel.Children)
            {
                question.Answers.Add(new Answer(answerContent.AnswerID)
                {
                    Name  = answerContent.AnswerName,
                    Right = answerContent.IsChecked
                });

                var getGoodAnswer = actualAnswers.Find(x => x.Name.Equals(answerContent.AnswerName));
                if (getGoodAnswer.Right == true)
                {
                    answerContent.ChangeAnswerWeightToColor("#56c649", change: true);
                    goodAnswers++;
                }
                else
                {
                    if (answerContent.IsChecked)
                    {
                        answerContent.ChangeAnswerWeightToColor("#dd2727", change: true);
                    }
                }

                if (answerContent.IsChecked == true)
                {
                    picks++;

                    if (answerContent.IsChecked == getGoodAnswer.Right)
                    {
                        pickedGoodAnswers++;
                    }
                }

                answerContent.Disable();
            }

            if (!(goodAnswers == pickedGoodAnswers && picks == pickedGoodAnswers))
            {
                if (QuestionManager.WrongAnsweredQuestions.Find(x => x.ID == question.ID) == null)
                {
                    QuestionManager.WrongAnsweredQuestions.Add(question);
                }
            }
            else
            {
                if (QuestionManager.GetWrongQuestion(question.ID) != null)
                {
                    QuestionManager.RemoveWrongQuestion(question.ID);
                }
            }

            CheckAnswersButton.IsEnabled = false;
            NextQuestionButton.IsEnabled = true;
            PrevQuestionButton.IsEnabled = true;

            GoodAnswerCountsLabel.Foreground = goodAnswers == pickedGoodAnswers && picks == pickedGoodAnswers ? Brushes.Green : Brushes.Red;
            GoodAnswerCountsLabel.Content    = $"{picks}/{pickedGoodAnswers}/{actualAnswers.Count}";

            ((CheckAnswersContent)TabManager.GetTab("Wrong answers").Content).UpdateQuestions();
        }