Exemplo n.º 1
0
        public ActionResult GetTests(AjaxGridRequest model)
        {
            var tests = TestService.GetAll();

            if (!User.IsCompany)
            {
                tests = tests.Where(x => x.Status == TestStatus.Edit);
            }
            if (User.IsCompany)
            {
                tests = tests.Where(x => x.CompanyId == User.CompanyID);
            }
            else if (User.InRole(Role.Admin))
            {
            }
            else if (User.IsEmployee)
            {
                tests = tests.Where(x => x.Author_TC == User.Employee_TC);
            }
            var list = tests.Select(x => new { x.Id, x.Name, x.Status })
                       .ToPagedList(model.Page - 1, model.Rows);

            return(Json(new GridData(list.PageCount,
                                     model.Page,
                                     list.Count,
                                     list.Select(x => new { x.Id, x.Name,
                                                            Status = NamedIdCache <TestStatus> .GetName(x.Status) })), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult GetModules(int testId, AjaxGridRequest model)
        {
            var list = TestModuleService
                       .GetAll(x => x.TestId == testId).Select(x => new { x.Id, x.Name }).ToPagedList(model.Page - 1, model.Rows);

            return(JsonGet(new GridData(list.PageCount,
                                        model.Page,
                                        list.Count,
                                        list)));
        }
Exemplo n.º 3
0
        public ActionResult GetGroupTests(int groupInfoId, AjaxGridRequest model)
        {
            var list = GroupTestService
                       .GetAll(x => x.GroupInfoId == groupInfoId)
                       .Select(x => new { x.Id, TestId = x.Test.Name }).ToPagedList(model.Page - 1, model.Rows);

            return(JsonGet(new GridData(list.PageCount,
                                        model.Page,
                                        list.ItemCount,
                                        list)));
        }
Exemplo n.º 4
0
        public ActionResult GetQuestions(int testId, AjaxGridRequest model)
        {
            var list = TestQuestionService.GetAll(x => x.TestId == testId)
                       .Select(x => new { x.Id, x.Description }).ToPagedList(model.Page - 1, model.Rows);

            list = list.Select(x => new { x.Id, Description = StringUtils.ReplaceGLT(x.Description) })
                   .ToPagedList(list);

            return(Json(new GridData(list.PageCount,
                                     model.Page,
                                     list.Count,
                                     list), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult GetAnswers(int questionId, AjaxGridRequest model)
        {
            var question = TestQuestionService.GetByPK(questionId);

            Expression <Func <TestAnswer, object> > selector = null;

            PagedList <object> list;

            switch (question.Type)
            {
            case TestQuestionType.OneAnswer:
            case TestQuestionType.ManyAnswers:
                var l1 = TestAnswerService.GetAll(x => x.QuestionId == questionId)
                         .Select(x => new {
                    x.Id,
                    x.Description,
                    IsRight = x.IsRight.GetValueOrDefault() ? "Да" : "Нет"
                }).ToPagedList(model.Page - 1, model.Rows);

                list = l1.Select(x => new {
                    x.Id,
                    Description = StringUtils.ReplaceGLT(x.Description),
                    x.IsRight
                }).Cast <object>().ToPagedList(l1);

                break;

            case TestQuestionType.Comparison:
                var l2 = TestAnswerService.GetAll(x => x.QuestionId == questionId)
                         .Select(x => new {
                    x.Id,
                    x.Description,
                    ComparableId = x.ComparableAnswer.Description
                }).ToPagedList(model.Page - 1, model.Rows);

                list = l2.Select(x => new {
                    x.Id,
                    Description = StringUtils.ReplaceGLT(x.Description),
                    x.ComparableId
                }).Cast <object>().ToPagedList(l2);
                break;

            case TestQuestionType.Sort:
                var l3 = TestAnswerService.GetAll(x => x.QuestionId == questionId)
                         .Select(x => new {
                    x.Id,
                    x.Description,
                    x.Sort
                }).ToPagedList(model.Page - 1, model.Rows);
                list = l3.Select(x => new {
                    x.Id,
                    Description = StringUtils.ReplaceGLT(x.Description),
                    x.Sort
                }).Cast <object>().ToPagedList(l3);
                break;

            default:
                throw new Exception("TestQuestionType out of range");
            }
            return(Json(new GridData(list.PageCount,
                                     model.Page,
                                     list.Count,
                                     list), JsonRequestBehavior.AllowGet));
        }