Ejemplo n.º 1
0
        public ClassPanorama Panorama(int classId, IList <int> academicYears, IList <StandardizedTestFilter> standardizedTestFilters)
        {
            BaseSecurity.EnsureAdminOrTeacher(Context);

            if (!Context.Claims.HasPermission(ClaimInfo.VIEW_PANORAMA))
            {
                throw new ChalkableSecurityException("You are not allowed to view class panorama");
            }

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

            standardizedTestFilters = standardizedTestFilters ?? new List <StandardizedTestFilter>();
            var componentIds = standardizedTestFilters.Select(x => x.ComponentId);
            var scoreTypeIds = standardizedTestFilters.Select(x => x.ScoreTypeId);

            var schoolYears = ServiceLocator.SchoolYearService.GetSchoolYearsByAcadYears(academicYears);
            var c           = ServiceLocator.ClassService.GetClassDetailsById(classId);

            if (c.SchoolYear != null)
            {
                schoolYears = schoolYears.Where(x => x.SchoolRef == c.SchoolYear.SchoolRef).ToList();
            }
            var sectionPanorama = ConnectorLocator.PanoramaConnector.GetSectionPanorama(classId, schoolYears.Select(x => x.Id).ToList(), componentIds.ToList(), scoreTypeIds.ToList());

            return(ClassPanorama.Create(sectionPanorama));
        }
Ejemplo n.º 2
0
        public static ClassPanoramaViewData Create(ClassDetails cClass, IList <StandardizedTestDetails> standardizedTests, ClassPanorama panorama,
                                                   IList <GradingScaleRange> gradingScaleRanges, IList <StudentDetailsInfo> classStudents, IList <int> selectedStudents, DateTime today)
        {
            var res = new ClassPanoramaViewData(cClass)
            {
                StandardizedTests             = standardizedTests.Select(x => StandardizedTestViewData.Create(x, x.Components, x.ScoreTypes)).ToList(),
                ClassDistributionSection      = ClassDistributionSectionViewData.Create(panorama.Grades, panorama.Absences, panorama.Infractions, gradingScaleRanges),
                StandardizedTestsStatsByClass = StandardizedTestStatsViewData.CreateForClass(panorama.StandardizedTests, standardizedTests),
                Students = new List <StudentStandardizedTestStats>()
            };

            classStudents = classStudents.OrderBy(x => x.FullName()).ToList();

            //Preparing students
            foreach (var student in classStudents)
            {
                var studentStats = StandardizedTestStatsViewData.CreateForStudent(student.Id, panorama.StandardizedTests, standardizedTests);
                var gradeAvg     = panorama.Grades?.FirstOrDefault(x => x.StudentId == student.Id)?.AverageGrade;
                var infractions  = panorama.Infractions?.FirstOrDefault(x => x.StudentId == student.Id)?.NumberOfInfractions;
                var absences     = panorama.Absences?.FirstOrDefault(x => x.StudentId == student.Id);

                res.Students.Add(StudentStandardizedTestStats.Create(student, gradeAvg, absences, infractions, studentStats));
            }

            if (selectedStudents == null || selectedStudents.Count == 0)
            {
                return(res);
            }

            var selected = panorama.StandardizedTests?.Where(x => selectedStudents.Contains(x.StudentId));

            res.SelectStandardizedTestsStats = StandardizedTestStatsViewData.CreateForClass(selected?.ToList(), standardizedTests);

            return(res);
        }