コード例 #1
0
ファイル: TestController.cs プロジェクト: luongabc/template
        public ActionResult ViewTest(int IdTest)
        {
            ETest test = TestContext.GetTestOfUser(IdTest);
            Tuple <List <EQuestion>, List <EUserResult> > data = BLTest.GetContentOfTest(test);
            List <Answer>      listAnserIsTrue = AnswerContext.GetByTest(IdTest);
            List <EQuestion>   eQuestions      = data.Item1.OrderBy(i => i.Id).ToList();
            List <EUserResult> userResults     = data.Item2.OrderBy(i => i.IdQuestion).ToList();

            for (int i = 0; i < data.Item2.Count; i++)
            {
                if (data.Item2[i].IdAnswer == listAnserIsTrue[i].Id)
                {
                    data.Item2[i].isTrue = listAnserIsTrue[i].result;
                }
            }
            ViewData["ContentTest"] = Tuple.Create(eQuestions, userResults);
            ViewData["Test"]        = test;
            return(View());
        }
コード例 #2
0
        public IEnumerable getQuestions(int id)
        {
            ETest test = TestContext.GetTestOfUser(id);

            if (test == null)
            {
                return(null);
            }
            if (test.Status == Entity.baseEmun.StaticTest.Finish.ToString())
            {
                return(null);
            }
            if (test.TimeStart != null)
            {
                DateTime timeNow = DateTime.Now;
                if (timeNow - test.TimeStart > test.Time)
                {
                    return(null);
                }
                test.Time = test.Time - (TimeSpan)(timeNow - test.TimeStart);
            }
            return(JsonConvert.SerializeObject(BLTest.GetContentOfTest(test)));
        }