public ActionResult Documentor() { int student_id = DocumentorDB.Students.Where(a => a.id.Equals(Request.Params["student_id"])).First().id; bool istest = bool.Parse(Request.Params["istest"]); bool ispractice = bool.Parse(Request.Params["ispractice"]); Assignment assignment; //If assignment exists if (DocumentorDB.Assignments.Where(a => a.student_id == student_id && a.ispractice.Equals(istest) && a.istest.Equals(ispractice) && a.iscomplete == false).ToList().Count != 0) assignment = DocumentorDB.Assignments.Where(a => a.student_id == student_id).First(); else //If assignment doesn't exists { Assignment a_new = new Assignment(); a_new.student_id = student_id; List<CaseStudy> case_studies; if (istest) case_studies = DocumentorDB.CaseStudies.Where(cs => cs.CaseStudyDockets.Count > 0 && cs.CaseStudyQuizs.Where(csq => csq.Quiz.isonline == true).Count() > 0).ToList(); else if (ispractice) case_studies = DocumentorDB.CaseStudies.Where(cs => cs.CaseStudyDockets.Count > 0).ToList(); else { case_studies = DocumentorDB.CaseStudies.Where(cs => cs.CaseStudyQuizs.Count() > 0).ToList(); //case_studies = DocumentorDB.CaseStudies.Where(cs => cs.CaseStudyQuizs.Where(csq => csq.Quiz.isonline == false).Count() > 0).ToList(); } Random r_no = new Random(); int new_case_study = r_no.Next(case_studies.Count); a_new.case_study_id = case_studies[new_case_study].id; a_new.level_id = DocumentorDB.Levels.First().id; DocumentorDB.Assignments.InsertOnSubmit(a_new); DocumentorDB.SubmitChanges(); assignment = DocumentorDB.Assignments.Where(a => a.student_id == student_id).First(); assignment.create_quiz(); assignment.create_docuchecks(); } if (istest) return RedirectToAction("PlayQuiz", new { assignment_id = assignment.id }); else if (ispractice) return RedirectToAction("ListDockets", new { assignment_id = assignment.id }); else return RedirectToAction("PlayQuiz", new { assignment_id = assignment.id }); }
public ActionResult Documentor() { int student_id = DocumentorDB.Students.Where(a => a.id.Equals(Request.Params["student_id"])).First().id; Assignment assignment; //If assignment exists if (DocumentorDB.Assignments.Where(a => a.student_id == student_id && a.istest.Equals(true) && a.iscomplete != true).ToList().Count != 0) assignment = DocumentorDB.Assignments.Where(a => a.student_id == student_id && a.istest.Equals(true) && a.iscomplete != true).First(); else //If assignment doesn't exists { Assignment a_new = new Assignment(); a_new.student_id = student_id; CaseStudy new_case_study = DocumentorDB.CaseStudies.Where(cs => cs.active == true).First(); a_new.case_study_id = new_case_study.id; a_new.level_id = new_case_study.level_id??DocumentorDB.Levels.First().id; a_new.istest = true; DocumentorDB.Assignments.InsertOnSubmit(a_new); DocumentorDB.SubmitChanges(); assignment = DocumentorDB.Assignments.Where(a => a.id== a_new.id).First(); assignment.create_docuchecks(); } return RedirectToAction("PlayQuiz", new { assignment_id = assignment.id }); }
public ActionResult TakePractice() { Docket docket = DocumentorDB.Dockets.Where(dkt => dkt.id.Equals(Request.Params["docket_id"])).First(); Document document = DocumentorDB.Documents.Where(dcmt => dcmt.id.Equals(Request.Params["document_id"])).First(); Student student=DocumentorDB.Students.Where(std=>std.id.Equals(Request.Params["student_id"])).First(); CaseStudy case_study=docket.CaseStudyDockets.First().CaseStudy; Assignment assignment = new Assignment(); assignment.case_study_id = case_study.id; assignment.student_id = student.id; assignment.level_id = DocumentorDB.Levels.First().id; assignment.ispractice = true; assignment.istest = false; assignment.isstarted = true; assignment.score = 0; DocumentorDB.Assignments.InsertOnSubmit(assignment); DocumentorDB.SubmitChanges(); assignment.create_docuchecks(document.id, docket.id); DocumentorDB.SubmitChanges(); Docucheck docucheck = DocumentorDB.Docuchecks.Where(dchk => dchk.docket_id == docket.id && dchk.document_id == document.id && (dchk.played == false || dchk.played == null)).First(); return RedirectToAction("PracticeDocument", new { docucheck_id = docucheck.id, sequence_number = 1 }); }
public ActionResult GoToTest() { Student student = DocumentorDB.Students.Where(s => s.id.Equals(Request.Params["student_id"])).First(); CaseStudy case_study = DocumentorDB.CaseStudies.Where(cs => cs.id.Equals(Request.Params["case_study_id"])).First(); Assignment assignment; //If assignment exists if (student.Assignments.Where(a => a.case_study_id.Equals(case_study.id) && a.istest.Equals(true) && a.iscomplete != true).ToList().Count != 0) assignment = student.Assignments.Where(a => a.case_study_id.Equals(case_study.id) && a.istest.Equals(true) && a.iscomplete != true).First(); else //If assignment doesn't exists { Assignment a_new = new Assignment(); a_new.student_id = student.id; a_new.case_study_id = case_study.id; a_new.level_id = case_study.level_id ?? DocumentorDB.Levels.First().id; a_new.istest = true; DocumentorDB.Assignments.InsertOnSubmit(a_new); DocumentorDB.SubmitChanges(); assignment = DocumentorDB.Assignments.Where(a => a.id == a_new.id).First(); assignment.create_docuchecks(); } if (assignment.CaseStudy.CaseStudyQuizs.Count > 0 && assignment.Responses.Count == 0) return RedirectToAction("PlayQuiz", new { assignment_id = assignment.id }); else return RedirectToAction("ListDocuments", new { assignment_id = assignment.id }); }
public ActionResult Index() { Student student = DocumentorDB.Students.Where(s => s.id.Equals(Request.Params["student_id"])).First(); List<CaseStudy> case_studies = DocumentorDB.CaseStudies.Where(cs => cs.Assignments.Where(a => a.student_id.Equals(student.id)).Count() > 0 || cs.active.Equals(true)).ToList(); List<Assignment> assignments = new List<Assignment>(); foreach (CaseStudy cs in case_studies) { string cs_name = cs.name; List<Assignment> cs_completed_assignments = cs.Assignments.Where(a => a.student_id.Equals(student.id) && a.iscomplete.Equals(true)).ToList(); int cs_attempts = cs_completed_assignments.Count; int cs_score = (int)(cs_completed_assignments.Sum(a => a.score) / cs_completed_assignments.Count); if (cs.Assignments.Where(a => a.student_id.Equals(student.id)).Count() > 0) assignments.Add(cs.Assignments.Where(a => a.student_id.Equals(student.id)).First()); else { Assignment a = new Assignment(); a.student_id = student.id; a.case_study_id = cs.id; a.level_id = cs.level_id ?? DocumentorDB.Levels.First().id; a.iscomplete = false; a.istest = true; a.ispractice = false; DocumentorDB.Assignments.InsertOnSubmit(a); DocumentorDB.SubmitChanges(); if (cs.CaseStudyDockets.Count > 0 || cs.CaseStudyDocuments.Count > 0) { a.create_docuchecks(); } assignments.Add(a); } } return View(assignments); }
public ActionResult StartPractice() { CaseStudy case_study = DocumentorDB.CaseStudies.Where(a => a.id == Int32.Parse(Request.Params["case_study_id"])).First(); Assignment assignment = new Assignment(); assignment.student_id = DocumentorDB.Students.Where(a => a.username.Equals(Request.Params["student_id"])).First().id; assignment.case_study_id = case_study.id; DocumentorDB.Assignments.InsertOnSubmit(assignment); return (RedirectToAction("PlayQuiz", new { assignment_id = assignment.id })); }
private void detach_Assignments(Assignment entity) { this.SendPropertyChanging(); entity.Student = null; }
private void attach_Assignments(Assignment entity) { this.SendPropertyChanging(); entity.Student = this; }
partial void DeleteAssignment(Assignment instance);
partial void UpdateAssignment(Assignment instance);
partial void InsertAssignment(Assignment instance);