/*private void Cbx_TopicList_SelectionChanged(object sender, SelectionChangedEventArgs e) * { * //To fetch the Questions on selection of the Topic and display in the listbox * comboselecteditemId = cbx_TopicList.SelectedIndex + 1; * string val = comboselecteditemId.ToString(); * var data = DbUtility.ReadXml<ObservableCollection<Question>>("Questions.xml"); * var Questions = from s in data where s.topicId.Equals(val) select s; * { * QuestionList.ItemsSource = Questions; * } * }*/ //private void QuestionList_SelectionChanged(object sender, SelectionChangedEventArgs e) //{ //} private void Btn_StartQuestion_Click(object sender, RoutedEventArgs e) { string times = timer.Text; int time = Convert.ToInt32(times); string val = ""; XmlDocument doc = new XmlDocument(); doc.Load("Questions.xml"); foreach (XmlNode x in doc.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionCode").InnerText == questionCode) { DisplayCode.Text = x.SelectSingleNode("questionCode").InnerText; } } // DisplayCode.Text = questionCode; var studentPage = new StudentCheckIt(time); studentPage.Show(); //MessageBoxResult result = System.Windows.MessageBox.Show("The Question code is " + val + ". Do you want to start the question? ", "Start Question", MessageBoxButton.YesNo); //switch (result) //{ // case MessageBoxResult.Yes: // var p = new StudentCheckIt(time); // studentPage.Show(); // break; // case MessageBoxResult.No: // var mainwindow = new MainWindow(); // mainwindow.Show(); // break; //} }
private void Btn_FinishQuiz_Click(object sender, RoutedEventArgs e) { var studentdata = DbUtility.ReadXml <ObservableCollection <Result> >("Results.xml"); XmlDocument docum = new XmlDocument(); docum.Load("Questions.xml"); foreach (XmlNode x in docum.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionCode").InnerText == questioncode) { string optAStatus = x.SelectSingleNode("optionAStatus").InnerText; string optBStatus = x.SelectSingleNode("optionBStatus").InnerText; string optCStatus = x.SelectSingleNode("optionCStatus").InnerText; string optDStatus = x.SelectSingleNode("optionDStatus").InnerText; string OptionAstatus = Convert.ToString(Chbx_A.IsChecked); string OptionBstatus = Convert.ToString(Chbx_B.IsChecked); string OptionCstatus = Convert.ToString(Chbx_C.IsChecked); string OptionDstatus = Convert.ToString(Chbx_D.IsChecked); if (OptionAstatus == optAStatus && OptionBstatus == optBStatus && OptionCstatus == optCStatus && OptionDstatus == optDStatus) { Result rs = new Result(); rs.questionCode = questioncode; rs.questionStatus = "Passed"; try { studentdata.Add(rs); DbUtility.WriteXml <ObservableCollection <Result> >(studentdata, "Results.xml"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { Result rs = new Result(); rs.questionCode = questioncode; rs.questionStatus = "Failed"; try { studentdata.Add(rs); DbUtility.WriteXml <ObservableCollection <Result> >(studentdata, "Results.xml"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } //MessageBox.Show("Your answer has been submitted successfully"); MessageBoxResult result = System.Windows.MessageBox.Show("Your answer has been submitted successfully. Do you want to close the application", "application close", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: var studentPage = new StudentCheckIt(time); this.Close(); break; case MessageBoxResult.Cancel: var studentCheckit = new StudentCheckIt(time); studentCheckit.Show(); break; } } } }