private void Window_Loaded(object sender, RoutedEventArgs e) { var data = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questions = from sn in data where sn.questionId.Equals(questionid) select sn; { stk_QuestionDetails.DataContext = Questions; } XmlDocument xdocum = new XmlDocument(); xdocum.Load("Questions.xml"); foreach (XmlNode x in xdocum.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionId").InnerText == questionid) { string topicids = x.SelectSingleNode("topicId").InnerText; int topicidas = Convert.ToInt32(topicids) + 1; topicid = Convert.ToString(topicidas); } } var topicdata = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = from tn in topicdata where tn.topicId.Equals(topicid) select tn; { stk_TopicName.DataContext = topic; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { var data = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var Topics = from s in data where s.topicId.Equals(topicid) select s; { stk_TopicName.DataContext = Topics; } }
public TopicDetail(string id) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; topicid = id; var topicdata = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topicdetails = from s in topicdata where s.topicId.Equals(topicid) select s; stk_TopicDetails.DataContext = topicdetails; }
private void Cbx_TopicName_SelectionChanged(object sender, SelectionChangedEventArgs e) { //To fetch the Questions on selection of the Topic and display in the listbox comboSelectedItemId = Cbx_TopicName.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; { Lbx_Questionlist.ItemsSource = Questions; } }
private void Btn_SaveQuestion_Click(object sender, RoutedEventArgs e) { try { var data = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var question = new ObservableCollection <Question>(); Question qs = new Question(); qs.topicId = topicid; XmlDocument doc = new XmlDocument(); doc.Load("Questions.xml"); int count = 1; foreach (XmlNode x in doc.SelectNodes("ArrayOfQuestion/Question")) { count = count + 1; } string questionid = Convert.ToString(count); qs.questionId = questionid; qs.questionDesc = QuestionDesciption.Text; qs.optionA = OptionA.Text; qs.optionB = OptionB.Text; qs.optionC = OptionC.Text; qs.optionD = OptionD.Text; //qs.corectionAnswer = CorrectAnswer.Text; qs.optionAStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionBStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionCStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionDStatus = Convert.ToString(Chbx_A.IsChecked); Random random = new Random(); var code = Convert.ToString(random.Next(999, 10000)); qs.questionCode = code; if (string.IsNullOrEmpty(QuestionDesciption.Text) || string.IsNullOrEmpty(OptionA.Text) || string.IsNullOrEmpty(OptionB.Text) || string.IsNullOrEmpty(OptionC.Text) || string.IsNullOrEmpty(OptionD.Text)) { MessageBox.Show("Please enter the values in all fields"); } else { data.Add(qs); DbUtility.WriteXml <ObservableCollection <Question> >(data, "Questions.xml"); MessageBox.Show("Question successfully added"); var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public QuestionDetail(string id) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; //fetch the project details from Projects.xml and display it on Projectdetail page. questionid = id; var questiondata = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questiondetails = from s in questiondata where s.questionId.Equals(questionid) select s; stk_QuestionDetails.DataContext = Questiondetails; }
private void Btn_Start_Click(object sender, RoutedEventArgs e) { // Count down timer logic DispatcherTimer dt = new DispatcherTimer(); dt.Interval = new TimeSpan(0, 0, 0, 1); dt.Tick += Dt_Tick; dt.Start(); //Enter quiz code screen logic InputBox.Visibility = System.Windows.Visibility.Collapsed; questioncode = InputTextBox.Text; InputTextBox.Text = String.Empty; // question display logic var questiondata = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questiondetails = from s in questiondata where s.questionCode.Equals(questioncode) select s; stk_QuestionDetails.DataContext = Questiondetails; XmlDocument xdocum = new XmlDocument(); xdocum.Load("Questions.xml"); foreach (XmlNode x in xdocum.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionCode").InnerText == questioncode) { string topicids = x.SelectSingleNode("topicId").InnerText; int topicidas = Convert.ToInt32(topicids) + 1; topicid = Convert.ToString(topicidas); } } var topicdata = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = from tn in topicdata where tn.topicId.Equals(topicid) select tn; { stk_topic.DataContext = topic; } }
private void Btn_SaveQuestion_Click(object sender, RoutedEventArgs e) { var pro = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var question = new ObservableCollection <Question>(); var qs = pro.First(f => f.questionId == QuestionId.Text); qs.questionDesc = Question.Text; qs.optionA = OptionA.Text; qs.optionB = OptionB.Text; qs.optionC = OptionC.Text; qs.optionD = OptionD.Text; qs.optionAStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionBStatus = Convert.ToString(Chbx_B.IsChecked); qs.optionCStatus = Convert.ToString(Chbx_C.IsChecked); qs.optionDStatus = Convert.ToString(Chbx_D.IsChecked); DbUtility.WriteXml <ObservableCollection <Question> >(pro, "Questions.xml"); MessageBox.Show("Question Successfully Updated"); var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); }
private void Btn_UpdateTopic_Click(object sender, RoutedEventArgs e) { var pro = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = new ObservableCollection <Topic>(); var tp = pro.First(f => f.topicId == Topicid.Text); tp.topicName = TopicName.Text; DbUtility.WriteXml <ObservableCollection <Topic> >(pro, "Topics.xml"); /*if (string.IsNullOrEmpty(TopicName.Text)) * { * MessageBox.Show("Please update the topic name"); * }*/ /*else * {*/ MessageBox.Show("Topic Successfully Updated"); var settings = new Settings(); settings.Show(); //} }
private void Btn_AddTopic_Click(object sender, RoutedEventArgs e) { try { var data = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = new ObservableCollection <Topic>(); Topic tn = new Topic(); XmlDocument doc = new XmlDocument(); doc.Load("Topics.xml"); int count = 1; foreach (XmlNode xn in doc.SelectNodes("ArrayOfTopic/Topic")) { count = count + 1; } string topicid = Convert.ToString(count); tn.topicId = topicid; tn.topicName = TopicName.Text; if (string.IsNullOrEmpty(TopicName.Text)) { MessageBox.Show("Please enter the topic name"); } else { data.Add(tn); DbUtility.WriteXml <ObservableCollection <Topic> >(data, "Topics.xml"); MessageBox.Show("Topic name successfully added"); var gobacktomain = new Settings(); gobacktomain.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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; } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // //((PieSeries)mcChart.Series[0]).ItemsSource = new KeyValuePair<string, int>[]{ // //new KeyValuePair<string, int>("Passed", 50), // //new KeyValuePair<string, int>("Failed", 50) }; int Failed = 0; int Passed = 0; int Count = 0; var data = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questions = from sn in data where sn.questionCode.Equals(questionCode) select sn; { stk_QuestionDetails.DataContext = Questions; } XmlDocument xdocum = new XmlDocument(); xdocum.Load("Questions.xml"); foreach (XmlNode x in xdocum.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionCode").InnerText == questionCode) { string topicids = x.SelectSingleNode("topicId").InnerText; int topicidas = Convert.ToInt32(topicids) + 1; topicid = Convert.ToString(topicidas); } } XmlDocument xydocum = new XmlDocument(); xydocum.Load("Questions.xml"); foreach (XmlNode xn in xdocum.SelectNodes("ArrayOfQuestion/Question")) { if (xn.SelectSingleNode("questionCode").InnerText == questionCode) { string answerA = xn.SelectSingleNode("optionAStatus").InnerText; string answerB = xn.SelectSingleNode("optionBStatus").InnerText; string answerC = xn.SelectSingleNode("optionCStatus").InnerText; string answerD = xn.SelectSingleNode("optionDStatus").InnerText; if (answerA == "True") { stk_CorrectAnswer.DataContext = xn.SelectSingleNode("optionA").InnerText; } else if (answerB == "True") { stk_CorrectAnswer.DataContext = xn.SelectSingleNode("optionB").InnerText; } else if (answerC == "True") { stk_CorrectAnswer.DataContext = xn.SelectSingleNode("optionC").InnerText; } else if (answerD == "True") { stk_CorrectAnswer.DataContext = xn.SelectSingleNode("optionD").InnerText; } } } var topicdata = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = from tn in topicdata where tn.topicId.Equals(topicid) select tn; { stk_topic.DataContext = topic; } //var question = new Question(); //question = (Question)QuestionList.SelectedItem; //string questioncode = question.questionCode; XmlDocument docum = new XmlDocument(); docum.Load("Results.xml"); foreach (XmlNode x in docum.SelectNodes("ArrayOfResult/Result")) { if (x.SelectSingleNode("questionCode").InnerText == questionCode) { //StudentResult.Visibility = System.Windows.Visibility.Visible; //stk_N0Result.Visibility = System.Windows.Visibility.Collapsed; Count = Count + 1; if (x.SelectSingleNode("questionStatus").InnerText == "Failed") { Failed = Failed + 1; } else { Passed = Passed + 1; } // if (Passed ==0 && Failed == 0) { } //((PieSeries)StudentResult.Series[0]).ItemsSource = new KeyValuePair<string, int>[]{ // new KeyValuePair<string, int>("Passed", Passed), // new KeyValuePair<string, int>("Failed", Failed) }; // } // //else // { // //StudentResult.Visibility = System.Windows.Visibility.Collapsed; // //stk_N0Result.Visibility = System.Windows.Visibility.Visible; // } ////To fetch the Topiclist and display in the listbox ///* List<string> data = new List<string>(); // XmlDocument docum = new XmlDocument(); // docum.Load("Topics.xml"); // foreach (XmlNode x in docum.SelectNodes("ArrayOfTopic/Topic")) // { // data.Add(x.SelectSingleNode("topicName").InnerText); // } // cbx_TopicList.ItemsSource = data; // cbx_TopicList.SelectedIndex = 0;*/' } } TotalStudent.Text = Count.ToString(); TotalFailed.Text = Failed.ToString(); TotalPassed.Text = Passed.ToString(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var topicnames = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); TopicNames.ItemsSource = topicnames; }