public ActionResult SubmitTest() { var session = (StudentLogin)Session[CommonConstants.STUDENT_SESSION]; var id_student = session.id_student; if (studentDao.getTesting(id_student) < 0) { return(View("Error")); } var id_thread = studentDao.getTesting(id_student); var list = studentDao.GetListQuest(studentDao.GetIdExam(id_student, id_thread), id_student); int total_quest = list.FirstOrDefault().thread.max_question; double coefficient = 10.0 / (double)total_quest; int count_correct = 0; foreach (var item in list) { if (item.student_thread.student_answer != null && item.student_thread.student_answer.Trim().Equals(item.question_exam.correct_answer.Trim())) { count_correct++; } } double score = Math.Round(coefficient * count_correct, 2); string detail = count_correct + "/" + total_quest; studentDao.InsertScore(score, id_student, id_thread); return(RedirectToAction("TestResult/" + id_thread)); }