コード例 #1
0
        /// <summary>
        /// handles submit buttons click event.
        /// Allows student to submit a quiz they are taking.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnSubmit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to submit this quiz?", "Submit", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                ResultData temp = new ResultData(GlobalData.currentUser, GlobalData.currentQuiz);
                foreach (QuestionBox ind in questionBoxes)
                {
                    for (int i = 0; i < ind.rbtnAnswers.Length; i++)
                    {
                        if (ind.rbtnAnswers[i].Checked)
                        {
                            temp.Answers.Add((AnswerData)ind.rbtnAnswers[i].Tag);
                        }
                    }
                }
                ResultsEntity res = new ResultsEntity();
                res.AddResult(temp);
                res.Dispose();

                MessageBox.Show("You scored " + ResultsController.GetStudentPercentage(GlobalData.currentUser, GlobalData.currentQuiz) + "%");
                GoBackToQuizzesView();
            }
        }