예제 #1
0
        ActionResult GetDetailsView(int id, string courseTC, int?moduleSetId)
        {
            var test = TestService.GetByPK(id);

            if (courseTC != null && CoursePrerequisiteService.GetTestIds(
                    courseTC).All(x => x != id))
            {
                return(NotFound());
            }

            if (!StudentInGroupService.CalcTestIsActive(test))
            {
                return(NotFound());
            }
            return(BaseView(Views.TestRun.Details, new TestRunDetailsVM {
                Test = test,
                CourseName = DictionaryUtils.GetValueNotDefaultKey(
                    CourseService.GetAllActiveCourseNames(), courseTC),
                ModuleSetId = moduleSetId,
                CourseTC = courseTC,
            }));
        }
예제 #2
0
        public ActionResult Details(int id)
        {
            if (id != 667 && User != null && User.IsRestricted)
            {
                return(Redirect("/"));
            }
            TestService.LoadWith(x => x.Author);
            var test = TestService.GetByPK(id);

            if (test == null)
            {
                return(null);
            }
            var isActiveCalc = StudentInGroupService.CalcTestIsActive(test);

            if (!isActiveCalc && (test.Status == TestStatus.Archive || test.CompanyId.HasValue))
            {
                return(null);
            }
            var testStat  = TestCalcService.GetByPK(id) ?? new TestCalc();
            var testStats = _.List(
                Tuple.Create("Пользователей сдавало", testStat.UserCount),
                Tuple.Create("Всего попыток", testStat.TryCount),
                Tuple.Create("Сданных тестов", testStat.PassCount)
                );
            var model = new TestVM {
                Test      = test,
                NextTests = SiteObjectService.GetSingleRelation <Test>(test)
                            .ToList(),
                IsActiveCalc = isActiveCalc,
                PrevTests    = SiteObjectService.GetByRelationObject <Test>(test).ToList(),
                Courses      = SiteObjectService.GetSingleRelation <Course>(test).ToList(),
                Sections     = SiteObjectService.GetSingleRelation <Section>(test).ToList(),
                TestStats    = testStats
            };

            return(BaseView(PartialViewNames.Details, model));
        }