private void SubmitButtonClick() { try { if (CommonData.SkipListItems.Count > 0 && !CommonData._time.ToString().Equals("-00:00:01")) { typeofquestion = CommonData.SkipListItems[0].TypeOfQuestion; FactoryGetSkippedObjectName factory1 = new FactoryGetSkippedObjectName(); Window window = factory1.GetClassObject(typeofquestion, true); CloseAction(); window.ShowDialog(); } else { ResultPageView resultPage = new ResultPageView(); CloseAction(); resultPage.ShowDialog(); } } catch (Exception) { throw; } }
private void NextButtonClick() { try { int index = 0; if (CommonData.count >= CommonData.SkipListItems.Count - 1) { if (Answer1IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer1 } }; } } else if (Answer2IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer2 } }; } } else if (Answer3IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer3 } }; } } else { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer4 } }; } } NextClickEnabled = false; SubmitClickEnabled = true; } else { if (Answer1IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer1 } }; } Answer1IsChecked = false; } else if (Answer2IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer2 } }; } Answer2IsChecked = false; } else if (Answer3IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer3 } }; } Answer3IsChecked = false; } else if (Answer4IsChecked) { if (!CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new MultipleChoiceQuestionsClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].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, CommonData.SkipListItems.Count); number = CommonData.CheckNumberSkip(number); CommonData.count++; typeofquestion = CommonData.SkipListItems[number].TypeOfQuestion; if (typeofquestion.Equals("Subjective")) { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (SubjectiveClass)CommonData.SkipListItems[number]); } else if (typeofquestion.Equals("MultipleChoice")) { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (MultipleChoiceQuestionsClass)CommonData.SkipListItems[number]); } else { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (MultipleOptionSelectClass)CommonData.SkipListItems[number]); } FactoryGetSkippedObjectName factory1 = new FactoryGetSkippedObjectName(); Window window = factory1.GetClassObject(typeofquestion, false); CloseAction(); window.ShowDialog(); } } catch (Exception ex) { throw; } }
private void NextButtonClick() { try { int index = 0; if (CommonData.count >= CommonData.SkipListItems.Count - 1) { if (CommonData.answerlist.Select(p => p.Questions).Contains(Questions)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new SubjectiveClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].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)) { index = CommonData.answerlist.FindIndex(p => p.Questions == Questions); CommonData.answerlist[index] = new SubjectiveClass { Questions = Questions, TypeOfQuestion = CommonData.SkipListItems[CommonData.count].TypeOfQuestion, Answers = new string[1] { Answer } }; } } else { MessageBox.Show("The answer cannot be blank please enter something", QuizGoApp.Properties.Resources.APPLICATION_NAME, MessageBoxButton.OK, MessageBoxImage.Error); return; } int number = random.Next(1, CommonData.SkipListItems.Count); number = CommonData.CheckNumberSkip(number); CommonData.count++; string typeofquestion = CommonData.SkipListItems[number].TypeOfQuestion; if (typeofquestion.Equals("Subjective")) { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (SubjectiveClass)CommonData.SkipListItems[number]); } else if (typeofquestion.Equals("MultipleChoice")) { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (MultipleChoiceQuestionsClass)CommonData.SkipListItems[number]); } else { CommonData.QuestionAnswersSkipListItems.Insert(CommonData.count, (MultipleOptionSelectClass)CommonData.SkipListItems[number]); } FactoryGetSkippedObjectName factory1 = new FactoryGetSkippedObjectName(); Window window = factory1.GetClassObject(typeofquestion, false); CloseAction(); window.ShowDialog(); } } catch (Exception ex) { throw; } }