public static ShortAverageViewData Create(ChalkableAverage average)
 {
     return(new ShortAverageViewData
     {
         AverageId = average.AverageId,
         AverageName = average.AverageName
     });
 }
Exemple #2
0
        public async Task <FinalGradeInfo> GetFinalGrade(int classId, GradingPeriod gradingPeriod)
        {
            var gradeBook = await GetGradeBook(classId, gradingPeriod, null, null, false);

            var averageDashBoard = GetAveragesDashboard(gradeBook, classId);
            var infractions      = ServiceLocator.InfractionService.GetInfractions();

            return(new FinalGradeInfo
            {
                Attendances = FinalStudentAttendance.Create(averageDashBoard.AttendanceSummary),
                Disciplines = FinalStudentDiscipline.Create(averageDashBoard.DisciplineSummary, infractions),
                GradeBook = gradeBook,
                Averages = gradeBook.Averages.GroupBy(x => x.AverageId)
                           .Select(x => ChalkableAverage.Create(x.Key, x.First().AverageName))
                           .ToList()
            });
        }
        public static IList <StudentFinalGradeViewData> Create(FinalGradeInfo finalGrade, ChalkableAverage average, IList <ClaimInfo> claims)
        {
            var res       = new List <StudentFinalGradeViewData>();
            var gradeBook = finalGrade.GradeBook;

            foreach (var student in gradeBook.Students)
            {
                var studentFinalGrade = new StudentFinalGradeViewData {
                    Student = StudentViewData.Create(student)
                };
                if (average != null)
                {
                    var stAvg = gradeBook.Averages.FirstOrDefault(x => x.AverageId == average.AverageId && x.StudentId == student.Id);
                    if (stAvg != null)
                    {
                        studentFinalGrade.CurrentStudentAverage = StudentAveragesViewData.Create(stAvg);
                    }
                }
                studentFinalGrade.StudentAverages = StudentAveragesViewData.Create(gradeBook.Averages.Where(x => x.StudentId == student.Id).ToList());
                IList <StudentAnnouncementDetails> stAnns = gradeBook.Announcements
                                                            .Where(a => a.StudentAnnouncements.Any(stAnn => stAnn.StudentId == student.Id))
                                                            .Select(a => a.StudentAnnouncements.First(stAnn => stAnn.StudentId == student.Id)).ToList();
                studentFinalGrade.StatsByType = StudentGradingByTypeStatsViewData.Create(gradeBook.Announcements.Select(x => x.ClassAnnouncementData).ToList(), stAnns, claims);
                var currentStAttendance = finalGrade.Attendances.FirstOrDefault(x => x.StudentId == student.Id);
                studentFinalGrade.Attendance = FinalStudentAttendanceViewData.Create(currentStAttendance, finalGrade.Attendances);
                var disciplines = finalGrade.Disciplines.Where(x => x.StudentId == student.Id).ToList();
                studentFinalGrade.Disciplines = disciplines.Select(x => new DisciplineTypeSummaryViewData
                {
                    Total = x.Occurrences,
                    Type  = DisciplineTypeViewData.Create(x.Infraction)
                }).ToList();
                res.Add(studentFinalGrade);
            }
            return(res);
        }
 public static GradingPeriodFinalGradeViewData Create(FinalGradeInfo finalGrade, ChalkableAverage average, IList <ClaimInfo> claims)
 {
     return(new GradingPeriodFinalGradeViewData
     {
         GradingPeriod = GradingPeriodViewData.Create(finalGrade.GradeBook.GradingPeriod),
         Averages = ShortAverageViewData.Create(finalGrade.Averages),
         CurrentAverage = average != null?ShortAverageViewData.Create(average) : null,
                              StudentFinalGrades = StudentFinalGradeViewData.Create(finalGrade, average, claims)
     });
 }