Exemple #1
0
        private void btnBeginTest_Click(object sender, EventArgs e)
        {
            studentMCQExamController smec = new studentMCQExamController();
            string   gotExamDate          = smec.getExamDate(comboBoxExamName.Text);
            DateTime examDateV            = DateTime.Parse(gotExamDate);
            DateTime localDate            = DateTime.Now;

            // MessageBox.Show(localDate.ToString());

            if (examDateV.Date > localDate.Date)
            {
                MessageBox.Show("You cant give exam before " + examDateV.ToString());
            }
            else
            {
                MessageBox.Show("Good luck for exam");
                pictureBoxHide.Visible = false;


                DataSet ds = smec.getQuestionToBank(setExamId);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        lblQuestionOne.Text      = ds.Tables[0].Rows[i]["question"].ToString();
                        radioBtnQOneOptionA.Text = ds.Tables[0].Rows[i]["optionA"].ToString();
                        radioBtnQOneOptionB.Text = ds.Tables[0].Rows[i]["optionB"].ToString();
                        radioBtnQOneOptionC.Text = ds.Tables[0].Rows[i]["optionC"].ToString();
                        radioBtnQOneOptionD.Text = ds.Tables[0].Rows[i]["optionD"].ToString();
                    }
                    else if (i == 1)
                    {
                        lblQuestionTwo.Text      = ds.Tables[0].Rows[i]["question"].ToString();
                        radioBtnQTwoOptionA.Text = ds.Tables[0].Rows[i]["optionA"].ToString();
                        radioBtnQTwoOptionB.Text = ds.Tables[0].Rows[i]["optionB"].ToString();
                        radioBtnQTwoOptionC.Text = ds.Tables[0].Rows[i]["optionC"].ToString();
                        radioBtnQTwoOptionD.Text = ds.Tables[0].Rows[i]["optionD"].ToString();
                    }
                    else if (i == 2)
                    {
                        lblQuestionThree.Text      = ds.Tables[0].Rows[i]["question"].ToString();
                        radioBtnQThreeOptionA.Text = ds.Tables[0].Rows[i]["optionA"].ToString();
                        radioBtnQThreeOptionB.Text = ds.Tables[0].Rows[i]["optionB"].ToString();
                        radioBtnQThreeOptionC.Text = ds.Tables[0].Rows[i]["optionC"].ToString();
                        radioBtnQThreeOptionD.Text = ds.Tables[0].Rows[i]["optionD"].ToString();
                    }
                    else
                    {
                        lblQuestionFour.Text      = ds.Tables[0].Rows[i]["question"].ToString();
                        radioBtnQFourOptionA.Text = ds.Tables[0].Rows[i]["optionA"].ToString();
                        radioBtnQFourOptionB.Text = ds.Tables[0].Rows[i]["optionB"].ToString();
                        radioBtnQFourOptionC.Text = ds.Tables[0].Rows[i]["optionC"].ToString();
                        radioBtnQFourOptionD.Text = ds.Tables[0].Rows[i]["optionD"].ToString();
                    }
                }
            }
        }
Exemple #2
0
        private void btnSubmit_Click_1(object sender, EventArgs e)
        {
            int counter = 0;
            studentMCQExamController smec = new studentMCQExamController();
            DataSet ds = smec.getQuestionToBank(setExamId);
            string  correctAnswerOne   = "";
            string  correctAnswerTwo   = "";
            string  correctAnswerThree = "";
            string  correctAnswerFour  = "";

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (i == 0)
                {
                    correctAnswerOne = ds.Tables[0].Rows[i]["correctOption"].ToString();
                }
                else if (i == 1)
                {
                    correctAnswerTwo = ds.Tables[0].Rows[i]["correctOption"].ToString();
                }
                else if (i == 2)
                {
                    correctAnswerThree = ds.Tables[0].Rows[i]["correctOption"].ToString();
                }
                else
                {
                    correctAnswerFour = ds.Tables[0].Rows[i]["correctOption"].ToString();
                }
            }
            foreach (Control c in groupBoxQuestionOne.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    if (c.Text == correctAnswerOne)
                    {
                        counter++;
                    }
                }
            }
            foreach (Control c in groupBoxQuestionTwo.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    if (c.Text == correctAnswerTwo)
                    {
                        counter++;
                    }
                }
            }
            foreach (Control c in groupBoxQuestionThree.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    if (c.Text == correctAnswerThree)
                    {
                        counter++;
                    }
                }
            }
            foreach (Control c in groupBoxQuestionFour.Controls)
            {
                if (c is RadioButton && ((RadioButton)c).Checked == true)
                {
                    if (c.Text == correctAnswerFour)
                    {
                        counter++;
                    }
                }
            }
            MessageBox.Show("your score is " + counter);
            scoreController sc = new scoreController();

            sc.addScore(sc.getExamId(comboBoxExamName.Text), sc.getStudentId(userNameStored), counter.ToString());
        }