Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();

            //}
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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;
                    }
                }
            }
        }