示例#1
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));
            }

            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));
        }
示例#2
0
        public void GetContext_AssesmentJustStarted_InitialDataSectionIs1()
        {
            Assesment          a       = new Assesment(DEFAULT_ID);
            AssesmentContextTO context = a.GetCurrentContext();

            Assert.AreEqual(1, context.SectionIndex);
        }
示例#3
0
        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));
        }