public ActionResult PlayQuiz() { Assignment assignment = DocumentorDB.Assignments.Where(a => a.id == Int32.Parse(Request.Params["assignment_id"])).First(); Quiz quiz = DocumentorDB.Quizs.Where(a => a.id == assignment.CaseStudy.CaseStudyQuizs.First().quiz_id).First(); var quiz_questions = new Dictionary<int, QuestionAnswers>(); List<Response> responses = new List<Response>(); foreach (Question q in quiz.QuizQuestions.Select(a => a.Question).ToList()) { quiz_questions.Add(q.id, new QuestionAnswers(q.id, q.question_content, q.question_type_id == 1 || q.question_type_id == 2 ? true : false, q.AnswerChoices.ToList())); Response r = new Response(); r.assignment_id = assignment.id; r.question_id = q.id; responses.Add(r); } ViewData["assignment"] = assignment; ViewData["quiz"] = quiz; //ViewData["quiz_questions"] = quiz.QuizQuestions.Select(a => a.Question).ToList(); ViewData["quiz_questions"] = quiz_questions; ViewData["responses"] = responses; ViewData["time_alloted"] = 30; return View(); }
public ActionResult SaveQuizData() { Quiz quiz = DocumentorDB.Quizs.Where(a => a.id == Int32.Parse(Request.Params["quiz_id"])).First(); Assignment assignment = DocumentorDB.Assignments.Where(a => a.id == Int32.Parse(Request.Params["assignment_id"])).First(); List<Question> quiz_questions = quiz.QuizQuestions.Select(a => a.Question).ToList(); foreach (Question q in quiz_questions) { if (Request.Params[q.id.ToString()] != null) { Response resp = new Response(); resp.question_id = q.id; resp.assignment_id = assignment.id; resp.response_content = Request.Params[q.id.ToString()]; DocumentorDB.Responses.InsertOnSubmit(resp); } } DocumentorDB.SubmitChanges(); //assignment.calculate_quiz_score(); //quiz.score = score; //DocumentorDB.SubmitChanges(); Random r = new Random(); List<Docket> dockets = DocumentorDB.Dockets.ToList(); int docket_index = r.Next(dockets.Count); return RedirectToAction("DocketDocumentsQuiz", new { assignment_id = assignment.id, docket_id = dockets[docket_index].id }); //return View(); }
private void detach_Responses(Response entity) { this.SendPropertyChanging(); entity.Assignment = null; }
private void detach_Responses(Response entity) { this.SendPropertyChanging(); entity.Question = null; }
partial void DeleteResponse(Response instance);
partial void UpdateResponse(Response instance);
partial void InsertResponse(Response instance);