public void CheckScore()
        {
            if (optionsListView.SelectedItem != null)
            {
                instruction.Text       = "Click on the correct answer";
                instruction.Foreground = Brushes.White;

                switch (tier)
                {
                case 0:
                    UpdateAnswers(callNumbers.Values.ElementAt(answer).High, answer1);
                    answer1.Visibility = Visibility.Visible;
                    Level("0 ", "00", 0, 1, 99);
                    tier++;
                    break;

                case 1:
                    UpdateAnswers(callNumbers.Values.ElementAt(answer).Mid, answer2);
                    answer2.Visibility = Visibility.Visible;
                    Level(" ", "0", 1, 2, 9);
                    tier++;
                    break;

                case 2:
                    UpdateAnswers(callNumbers.Values.ElementAt(answer).Low, answer3);
                    answer3.Visibility = Visibility.Visible;
                    tier             = 0;
                    _timer.IsEnabled = false;

                    historyPanel.Children.Insert(0, elementFunctions.GetScoreCard($"{correct}/3. {score.getScoreStatement(correct, 3)}", scores.Count, (Style)FindResource("MaterialDesignBody2TextBlock")));
                    Double tempScore = (Double)correct / (Double)3;
                    tempScore *= 100;
                    scores.Add((int)tempScore);
                    averageScore.Text = $"{(int)scores.Average()}%";
                    testsTaken.Text   = scores.Count().ToString();

                    checkOrder.Visibility = Visibility.Collapsed;
                    reset.Visibility      = Visibility.Visible;
                    break;
                }
            }
            else
            {
                instruction.Text       = "Please select and answer from the list";
                instruction.Foreground = Brushes.Red;
            }
        }
Exemplo n.º 2
0
        public void CheckScore()
        {
            Score score = new Score();

            correct = 0;

            ReplaceBooksList.ItemContainerStyle = null;
            correctOrder.Sort();
            for (int i = 0; i < correctOrder.Count; i++)
            {
                String temp1 = ReplaceBooksList.Items.GetItemAt(i).ToString(), temp2 = correctOrder.ElementAt(i);
                if (temp1.Equals(temp2))
                {
                    correctBooksList.Items.Add(new ListBoxItem {
                        Content = correctOrder.ElementAt(i), Background = Brushes.DarkGreen
                    });
                    correct++;
                }
                else
                {
                    correctBooksList.Items.Add(new ListBoxItem {
                        Content = correctOrder.ElementAt(i), Background = Brushes.DarkRed
                    });
                }
            }
            correctBooksList.HorizontalContentAlignment = HorizontalAlignment.Center;
            historyPanel.Children.Insert(0, elementFunctions.GetScoreCard($"{correct}/{matches}. {score.getScoreStatement(correct, matches)}", scores.Count, (Style)FindResource("MaterialDesignBody2TextBlock")));

            Double tempScore = (Double)correct / (Double)matches;

            tempScore *= 100;
            scores.Add((int)tempScore);
            averageScore.Text = $"{(int)scores.Average()}%";
            testsTaken.Text   = scores.Count().ToString();

            checkOrder.Visibility = Visibility.Collapsed;
            reset.Visibility      = Visibility.Visible;
        }
        public void CheckScore()
        {
            SecondList.ItemContainerStyle = null;
            SecondList.ItemsSource        = null;
            correct = 0;

            switch (ListToggle.IsChecked)
            {
            case false:
                for (int i = 0; i < matches; i++)
                {
                    if (values[i] == callNumbers.Values.ElementAt(i).High)
                    {
                        SecondList.Items.Add(new ListBoxItem {
                            Content = callNumbers.Values.ElementAt(i).High, Background = Brushes.DarkGreen
                        });
                        correct++;
                    }
                    else
                    {
                        SecondList.Items.Add(new ListBoxItem {
                            Content = callNumbers.Values.ElementAt(i).High, Background = Brushes.DarkRed
                        });
                    }
                }
                break;

            case true:
                List <String> temp = new List <String>();
                foreach (String item in keys)
                {
                    temp.Add(randomGen.GenerateDescriptions(item).High);
                }
                for (int i = 0; i < matches; i++)
                {
                    if (temp[i] == callNumbers.Values.ElementAt(i).High)
                    {
                        SecondList.Items.Add(new ListBoxItem {
                            Content = callNumbers.Keys.ElementAt(i), Background = Brushes.DarkGreen
                        });
                        correct++;
                    }
                    else
                    {
                        SecondList.Items.Add(new ListBoxItem {
                            Content = callNumbers.Keys.ElementAt(i), Background = Brushes.DarkRed
                        });
                    }
                }
                break;
            }
            historyPanel.Children.Insert(0, elementFunctions.GetScoreCard($"{correct}/{matches}. {score.getScoreStatement(correct, matches)}", scores.Count, (Style)FindResource("MaterialDesignBody2TextBlock")));

            Double tempScore = (Double)correct / (Double)matches;

            tempScore *= 100;
            scores.Add((int)tempScore);
            averageScore.Text = $"{(int)scores.Average()}%";
            testsTaken.Text   = scores.Count().ToString();

            checkOrder.Visibility = Visibility.Collapsed;
            reset.Visibility      = Visibility.Visible;
        }