Exemplo n.º 1
0
        private static ClassProfilePanoramaSetting GetDefaultClassPanoramaSettings(IServiceLocatorSchool serviceLocator, int?classId)
        {
            if (!classId.HasValue)
            {
                Trace.Assert(serviceLocator.Context.SchoolYearId.HasValue);
                var sy = serviceLocator.SchoolYearService.GetSchoolYearById(serviceLocator.Context.SchoolYearId.Value);
                return(new ClassProfilePanoramaSetting {
                    AcadYears = new List <int> {
                        sy.AcadYear
                    }
                });
            }

            var @class = serviceLocator.ClassService.GetById(classId.Value);

            var currentSchoolYear = @class.SchoolYearRef.HasValue
                ? serviceLocator.SchoolYearService.GetSchoolYearById(@class.SchoolYearRef.Value)
                : serviceLocator.SchoolYearService.GetCurrentSchoolYear();

            var adminPanoramaSettings = serviceLocator.PanoramaSettingsService.Get <AdminPanoramaSettings>(null);
            var previousSchoolYear    = serviceLocator.SchoolYearService.GetPreviousSchoolYears(currentSchoolYear.Id, adminPanoramaSettings.PreviousYearsCount);

            var res = new ClassProfilePanoramaSetting
            {
                AcadYears = previousSchoolYear.Select(x => x.AcadYear).ToList(),
                StandardizedTestFilters = adminPanoramaSettings.CourseTypeDefaultSettings
                                          ?.FirstOrDefault(x => x.CourseTypeId == @class.CourseTypeRef)
                                          ?.StandardizedTestFilters ?? new List <StandardizedTestFilter>()
            };

            res.AcadYears.Add(currentSchoolYear.AcadYear);

            return(res);
        }
Exemplo n.º 2
0
        public ActionResult Panorama(int classId, ClassProfilePanoramaSetting settings, IList <int> selectedStudents)
        {
            if (!Context.Claims.HasPermission(ClaimInfo.VIEW_PANORAMA))
            {
                throw new ChalkableSecurityException("You are not allowed to view class panorama");
            }

            if (settings.AcadYears == null)
            {
                settings = SchoolLocator.PanoramaSettingsService.Get <ClassProfilePanoramaSetting>(classId);
            }

            if (settings.AcadYears.Count == 0)
            {
                throw new ChalkableException("School years is required parameter");
            }

            var classDetails            = SchoolLocator.ClassService.GetClassDetailsById(classId);
            var standardizedTestDetails = SchoolLocator.StandardizedTestService.GetListOfStandardizedTestDetails();
            var panorama     = SchoolLocator.ClassService.Panorama(classId, settings.AcadYears, settings.StandardizedTestFilters);
            var gradingScale = SchoolLocator.GradingScaleService.GetClassGradingScaleRanges(classId);

            var classStudents = SchoolLocator.StudentService.GetClassStudentsDetails(classId, true);

            var panoramaViewData = ClassPanoramaViewData.Create(classDetails, standardizedTestDetails,
                                                                panorama, gradingScale, classStudents, selectedStudents, Context.NowSchoolTime);

            panoramaViewData.FilterSettings = ClassProfilePanoramaSettingsViewData.Create(settings);

            return(Json(panoramaViewData));
        }
Exemplo n.º 3
0
        public ActionResult SavePanoramaSettings(int classId, ClassProfilePanoramaSetting setting)
        {
            if (!Context.Claims.HasPermission(ClaimInfo.VIEW_PANORAMA))
            {
                throw new ChalkableSecurityException("You are not allowed to change panorama settings");
            }

            if (setting.AcadYears == null || setting.AcadYears.Count == 0)
            {
                throw new ChalkableException("Academic years is required parameter");
            }

            SchoolLocator.PanoramaSettingsService.Save(setting, classId);
            return(Json(true));
        }
 protected ClassProfilePanoramaSettingsViewData(ClassProfilePanoramaSetting setting) : base(setting.AcadYears, setting.StandardizedTestFilters)
 {
 }
 public static ClassProfilePanoramaSettingsViewData Create(ClassProfilePanoramaSetting setting)
 {
     return(setting == null ? null : new ClassProfilePanoramaSettingsViewData(setting));
 }