示例#1
0
 public static StudentPanoramaViewData Create(int studentId, StudentPanoramaInfo panorama, StudentProfilePanoramaSetting settings, IList <StandardizedTestDetails> tests)
 {
     return(new StudentPanoramaViewData
     {
         StandardizedTestsStats = StandardizedTestStatsViewData.CreateForStudent(studentId, panorama.StandardizedTests, tests),
         Absences = panorama.DailyAbsences?.Select(StudentDailyAbsenceViewData.Create).OrderBy(x => x.Date).ToList(),
         DisciplineStats = panorama.Infractions?.Select(StudentInfractionViewData.Create).OrderBy(x => x.OccurrenceDate).ToList(),
         AttendanceStats = BuildAttendanceStats(panorama.DailyAbsences, panorama.AllSchoolDays),
         DailyDisciplineStats = BuildDisciplineStats(panorama.Infractions, panorama.AllSchoolDays),
         FilterSettings = settings,
         StandardizedTests = tests.Select(x => StandardizedTestViewData.Create(x, x.Components, x.ScoreTypes)).ToList(),
         Calendars = StudentPanoramaCalendarViewData.Create(panorama.DailyAbsences, panorama.Infractions, panorama.AllSchoolDays, panorama.SchoolYears)
     });
 }
示例#2
0
        public async Task <StudentPanoramaInfo> Panorama(int studentId, IList <int> acadYears, 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 (acadYears == null || acadYears.Count == 0)
            {
                throw new ChalkableException("Academic 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(acadYears);
            var studentSchoolYears = ServiceLocator.SchoolYearService.GetSchoolYearsByStudent(studentId, StudentEnrollmentStatusEnum.CurrentlyEnrolled, null);

            schoolYears = schoolYears.Where(x => studentSchoolYears.Any(y => y.Id == x.Id)).ToList();
            var schoolYearIds = schoolYears.Select(x => x.Id).ToList();

            var             tasks           = schoolYearIds.Select(syId => Task.Run(() => ServiceLocator.CalendarDateService.GetLastDays(syId, true, null, Context.NowSchoolYearTime))).ToList();
            StudentPanorama studentPanorama = null;

            if (schoolYearIds.Count > 0)
            {
                studentPanorama = ConnectorLocator.PanoramaConnector.GetStudentPanorama(studentId, schoolYearIds, componentIds.ToList(), scoreTypeIds.ToList());
            }

            var days = (await Task.WhenAll(tasks)).SelectMany(x => x).OrderBy(x => x.Day).ToList();

            return(StudentPanoramaInfo.Create(studentPanorama, days, schoolYears));
        }