Esempio n. 1
0
 ///Метод для оновлення Ліста зі всіма тестами
 public void UpdateListView()
 {
     listView.Items.Clear();
     ProgramLogic.JSONHelper json = new ProgramLogic.JSONHelper();
     foreach (var item in json.Tests)
     {
         listView.Items.Add(new { Name = item.TestName, Result = ResultExamp.GetResult(item.TestName, login) });
     }
 }
        ///Кнопка для переходу до наступного питання і якщо це останнє питання, завершення тесту.
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (position + 2 == test.Questions.Count)
            {
                button1.Content = "End Test";
            }
            if (position + 1 < test.Questions.Count)
            {
                position++;
                textBox.Text           = test.Questions[position].Text;
                radioButton1.Content   = test.Questions[position].AnswerChoices[0];
                radioButton2.Content   = test.Questions[position].AnswerChoices[1];
                radioButton3.Content   = test.Questions[position].AnswerChoices[2];
                radioButton4.Content   = test.Questions[position].AnswerChoices[3];
                radioButton1.IsChecked = radioButton2.IsChecked = radioButton3.IsChecked = radioButton4.IsChecked = false;
                if (answer[position] != 0)
                {
                    switch (answer[position])
                    {
                    case 1: radioButton1.IsChecked = true; break;

                    case 2: radioButton2.IsChecked = true; break;

                    case 3: radioButton3.IsChecked = true; break;

                    case 4: radioButton4.IsChecked = true; break;
                    }
                }
            }
            else
            {
                int result = 0;
                for (int i = 0; i < test.Questions.Count; i++)
                {
                    if (rightAnswers[i] == userAnswers[i])
                    {
                        result += 1;
                    }
                }
                ResultExamp.SetExampResult(test.TestName, login, result);
                MessageBox.Show("Your result is " + result);
                this.Close();
            }
        }