public ActionResult Create(CourseResult courseresult)
        {
            if (ModelState.IsValid)
            {
                db.CourseResults.Add(courseresult);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.QuestionID = new SelectList(db.CourseQuestions, "QuestionID", "QuestionAnswer", courseresult.QuestionID);
            ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", courseresult.UserId);
            return View(courseresult);
        }
 public ActionResult Edit(CourseResult courseresult)
 {
     if (ModelState.IsValid)
     {
         db.Entry(courseresult).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.QuestionID = new SelectList(db.CourseQuestions, "QuestionID", "QuestionAnswer", courseresult.QuestionID);
     ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", courseresult.UserId);
     return View(courseresult);
 }
        /// <summary>
        /// Function that Updates the CourseResult table with whether the answer is correct or not.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="Answer"></param>
        public void UpdateTestResults(int id, string Answer)
        {
            var query = (from c in db.CourseQuestions
                         where c.QuestionID == id && c.QuestionCorrectAnswer == Answer
                         select c).Any();

            Guid UID = (Guid)(System.Web.Security.Membership.GetUser().ProviderUserKey);
            var courseResult = new CourseResult() { QuestionID = id, Correct = query, UserId = UID };
            db.CourseResults.Add(courseResult);
            db.SaveChanges();
        }