Exemplo n.º 1
0
        public ActionResult GetModulesAuto(int testId, string term)
        {
            term = term ?? string.Empty;
            var list = TestModuleService.GetAll(x => x.TestId == testId && x.Name.Contains(term))
                       .Select(x => Select2VM.Item(x.Id, x.Name));

            return(Json(new Select2VM(list), 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 EditTest(int?id)
        {
            var        test            = new Test();
            AjaxGridVM modulesModel    = null;
            AjaxGridVM moduleSetsModel = null;
            AjaxGridVM questionsModel  = null;
            var        modules         = new List <TestModule>();
            var        modulePercents  = new Dictionary <int, int>();

            if (id.HasValue)
            {
                TestService.LoadWith(x => x.TestPassRule);
                test = TestService.GetByPK(id);
                EditTestPermission(test.Id);
                modulesModel = new AjaxGridVM {
                    GetListUrl = Url.Action <TestEditController>(c => c.GetModules(id.Value, null)),
                    EditUrl    = Url.Action <TestEditController>(c => c.EditModule(id.Value, null)),
                    DeleteUrl  = Url.Action <TestEditController>(c => c.DeleteModule(null)),
                    Caption    = "Модули"
                };
                AddColumns <TestModule>(modulesModel, x => x.Name);
                moduleSetsModel = new AjaxGridVM {
                    GetListUrl = Url.Action <TestEditController>(c => c.GetModuleSets(id.Value, null)),
                    EditUrl    = Url.Action <TestEditController>(c => c.EditModuleSet(id.Value, null)),
                    Caption    = "План тестирования"
                };
                AddColumns <TestModuleSet>(moduleSetsModel, x => x.Number);
                AddColumns <TestModuleSet>(moduleSetsModel, x => x.Description);
                questionsModel = new AjaxGridVM {
                    GetListUrl = Url.Action <TestEditController>(c => c.GetQuestions(id.Value, null)),
                    EditUrl    = Url.Action <TestEditController>(c => c.EditQuestion(id.Value, null)),
                    DeleteUrl  = Url.Action <TestEditController>(c => c.DeleteQuestion(null)),
                    Caption    = "Вопросы"
                };
                AddColumns <TestQuestion>(questionsModel, x => x.Description);
                modulePercents = EntityUtils.GetModulePercents(test.TestPassRule);
                modules        = TestModuleService.GetAll(x => x.TestId == id.Value).ToList();
            }
            test.TestPassRule = test.TestPassRule ?? new TestPassRule();

            var testEditVM = new TestEditVM {
                Test       = test,
                CourseName = CourseService.AllCourseLinks()
                             .GetValueOrDefault(test.CourseTCList).GetOrDefault(x => x.WebName),
                Modules        = modules,
                ModulePercents = modulePercents
            };

            return(BaseView(
                       new PagePart(new TestEditView().Init(testEditVM, Url)),
                       modulesModel == null ? null : new PagePart(PartialViewNames.AjaxList, modulesModel),
                       questionsModel == null ? null : new PagePart(PartialViewNames.AjaxList, questionsModel),
                       moduleSetsModel == null || test.CompanyId.HasValue ? null : new PagePart(PartialViewNames.AjaxList, moduleSetsModel)
                       ));
        }