private void NextButtonClick()
        {
            try
            {
                if (CommonData.QuestionAnswerList.Count >= 10)
                {
                    if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                    {
                        CommonData.answerlist.Add(new SubjectiveClass
                        {
                            Questions      = Questions,
                            TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                            Answers        = new string[1] {
                                Answer
                            }
                        });
                    }
                    PreviousClickEnabled = false;
                    NextClickEnabled     = false;
                    SubmitClickEnabled   = true;
                }
                else
                {
                    if (!string.IsNullOrEmpty(Answer))
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new SubjectiveClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer
                                }
                            });
                        }
                    }
                    else
                    {
                        MessageBox.Show("The answer cannot be blank please enter something", Properties.Resources.APPLICATION_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    number = random.Next(1, 17);
                    number = CommonData.CheckNumber(number);
                    CommonData.i++;
                    typeofquestion = QuestionAnswerCollectionClass.commonQuestions[number].TypeOfQuestion;
                    typeofquestion = RecursiveMethod(typeofquestion);

                    FactoryGetObjectName factory = new FactoryGetObjectName();
                    Window window = factory.GetClassObject(typeofquestion);
                    CloseAction();
                    window.ShowDialog();
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
 private void PreviousButtonClick()
 {
     try
     {
         CommonData.i--;
         CommonData.previousclickflag = true;
         FactoryGetObjectName factory = new FactoryGetObjectName();
         Window window = factory.GetClassObject(CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion);
         CloseAction();
         window.ShowDialog();
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
        private void NextButtonClick()
        {
            try
            {
                if (CommonData.QuestionAnswerList.Count >= 10)
                {
                    if (Answer1IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer1
                                }
                            });
                        }
                    }
                    else if (Answer2IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer2
                                }
                            });
                        }
                    }
                    else if (Answer3IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer3
                                }
                            });
                        }
                    }
                    else
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer4
                                }
                            });
                        }
                    }
                    PreviousClickEnabled = false;
                    NextClickEnabled     = false;
                    SubmitClickEnabled   = true;
                }
                else
                {
                    if (Answer1IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer1
                                }
                            });
                        }
                        Answer1IsChecked = false;
                    }
                    else if (Answer2IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer2
                                }
                            });
                        }
                        Answer2IsChecked = false;
                    }
                    else if (Answer3IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer3
                                }
                            });
                        }
                        Answer3IsChecked = false;
                    }
                    else if (Answer4IsChecked)
                    {
                        if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions))
                        {
                            CommonData.answerlist.Add(new MultipleChoiceQuestionsClass
                            {
                                Questions      = Questions,
                                TypeOfQuestion = CommonData.QuestionAnswerList[CommonData.i].TypeOfQuestion,
                                Answers        = new string[1] {
                                    Answer4
                                }
                            });
                        }
                        Answer4IsChecked = false;
                    }
                    else if (!Answer1IsChecked && !Answer2IsChecked && !Answer3IsChecked && !Answer4IsChecked)
                    {
                        MessageBox.Show(Properties.Resources.NO_OPTION_SELECTED_ERROR, Properties.Resources.APPLICATION_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    number = random.Next(1, 17);
                    number = CommonData.CheckNumber(number);
                    CommonData.i++;
                    typeofquestion = QuestionAnswerCollectionClass.commonQuestions[number].TypeOfQuestion;
                    typeofquestion = RecursiveMethod(typeofquestion);

                    FactoryGetObjectName factory = new FactoryGetObjectName();
                    Window window = factory.GetClassObject(typeofquestion);
                    CloseAction();
                    window.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }