public string insert_answer(AnswerProvider answer)
        {
            string        user_message;
            SqlConnection sqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connection"].ConnectionString);

            try
            {
                SqlCommand sqlCmd = new SqlCommand("[answered_question]", sqlConnection);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.Add("@student_results_fk_student", SqlDbType.Int).Value  = answer.student_results_fk_student;
                sqlCmd.Parameters.Add("@student_results_fk_question", SqlDbType.Int).Value = answer.student_results_fk_question;
                sqlCmd.Parameters.Add("@student_results_selected_answer", SqlDbType.NVarChar, 200).Value = answer.student_results_selected_answer;
                sqlCmd.Parameters.Add("@student_results_date", SqlDbType.DateTime).Value = answer.student_results_date;

                sqlConnection.Open();
                sqlCmd.ExecuteNonQuery();
                return(user_message = "Answer Submitted!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(user_message = "Failure!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
        private void bt_submit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (rbt_answer_a.IsChecked == true)
                {
                    selected_answer = Convert.ToString(rbt_answer_a.Content);
                }
                else if (rbt_answer_b.IsChecked == true)
                {
                    selected_answer = Convert.ToString(rbt_answer_b.Content);
                }
                else if (rbt_answer_c.IsChecked == true)
                {
                    selected_answer = Convert.ToString(rbt_answer_c.Content);
                }
                else if (rbt_answer_d.IsChecked == true)
                {
                    selected_answer = Convert.ToString(rbt_answer_d.Content);
                }


                if (selected_answer.Equals(correct_answer))
                {
                    current_score++;
                    lbl_score.Content = "Score : " + Convert.ToString(current_score);
                }


                next_question_number = connect.returnconnection_string("SELECT min(question_id) FROM Questions WHERE question_fk_course =" + current_course_id + " AND question_id > " + question_key);
                if (next_question_number.Equals(""))
                {
                    AnswerProvider answer = new AnswerProvider();
                    answer.student_results_fk_student      = StudentLogin.student_uid;
                    answer.student_results_fk_question     = question_key;
                    answer.student_results_selected_answer = selected_answer;
                    answer.student_results_date            = System.DateTime.Now;

                    AnswerHandler answerHandler = new AnswerHandler();
                    string        user_message  = answerHandler.insert_answer(answer);

                    ScoreProvider score = new ScoreProvider();
                    score.student_course_fk_student_uid = StudentLogin.student_uid;
                    score.student_course_fk_course_id   = current_course_id;
                    score.student_course_grade          = Convert.ToDecimal(current_score / total_questions);

                    ScoreHandler scoreHandler = new ScoreHandler();
                    string       use_message  = scoreHandler.insert_score(score);

                    MessageBox.Show(user_message);
                    MessageBox.Show("Exam is over. Please wait.");

                    TestSelector testSelector = new TestSelector();
                    testSelector.Show();
                }
                else
                {
                    AnswerProvider answer = new AnswerProvider();
                    answer.student_results_fk_student      = StudentLogin.student_uid;
                    answer.student_results_fk_question     = question_key;
                    answer.student_results_selected_answer = selected_answer;
                    answer.student_results_date            = System.DateTime.Now;

                    AnswerHandler answerHandler = new AnswerHandler();
                    string        user_message  = answerHandler.insert_answer(answer);
                    MessageBox.Show(user_message);

                    load_page(current_course_id);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please select an answer.");
            }
        }