public ActionResult GetContext() { Assesment assesment = Session[SESSION_ASSESMENT_OBJECT] != null ? (Assesment)Session[SESSION_ASSESMENT_OBJECT] : null; if (assesment == null) { return(Json(new { }, JsonRequestBehavior.AllowGet)); } AssesmentContextTO ctx = assesment.GetCurrentContext(); var questions = (from c in ctx.CurrentSectionQuestions select new { Answers = (from a in c.Answers select new { AnswerId = a.AnswerId, Text = a.Text }), QuestionId = c.QuestionId, Text = c.Text, Type = c.Type }); return(Json(new { SectionIndex = ctx.SectionIndex, QuestionIndex = ctx.QuestionIndex, MinutesLeft = ctx.MinutesLeft, CurrentSectionQuestions = questions }, JsonRequestBehavior.AllowGet)); }
public void GetContext_AssesmentJustStarted_InitialDataSectionIs1() { Assesment a = new Assesment(DEFAULT_ID); AssesmentContextTO context = a.GetCurrentContext(); Assert.AreEqual(1, context.SectionIndex); }
public void UpdateLeftTime_TimeRunOut_MinutesLeftStillZero() { Assesment a = new Assesment(DEFAULT_ID); a.Start(); a.UpdateLeftTime(); AssesmentContextTO context = a.GetCurrentContext(); Assert.AreEqual(true, context.MinutesLeft >= 0); }
public ActionResult GetContext() { Assesment assesment = Session[SESSION_ASSESMENT_OBJECT] != null ? (Assesment)Session[SESSION_ASSESMENT_OBJECT] : null; if (assesment == null) { return(Json(new { }, JsonRequestBehavior.AllowGet)); } return(Json(assesment.GetCurrentContext(), JsonRequestBehavior.AllowGet)); }