Example #1
0
 public static IList <ClassAvgViewData> Create(IList <StudentGradingByClass> studentGradingsByClass, int studentId, IList <ClaimInfo> claims)
 {
     return(studentGradingsByClass.Select(gragingByClass => new ClassAvgViewData
     {
         Avg = gragingByClass.Avg,
         ClassId = gragingByClass.ClassId,
         Items = gragingByClass.GradingsByAnnType.Select(gradingByType => new ClassCategoryAvgViewData
         {
             AnnouncementType = ClassAnnouncementTypeViewData.Create(gradingByType.AnnouncementType),
             Avg = gradingByType.Avg,
             Items = gradingByType.ClassAnnouncements.Select(ca =>
             {
                 var stAnns = gradingByType.StudentAnnouncements.Where(sa => sa.ActivityId == ca.SisActivityId).ToList();
                 return ShortAnnouncementGradeViewData.Create(ca, stAnns, studentId, claims);
             }).ToList()
         }).ToList()
     }).ToList());
 }
        public static GradingGridViewData Create(ChalkableGradeBook gradeBook, IList <ClaimInfo> claims)
        {
            var res = new GradingGridViewData(gradeBook)
            {
                Students = new List <GradeStudentViewData>()
            };

            if (gradeBook.Options != null)
            {
                res.DisplayAlphaGrades       = gradeBook.Options.DisplayAlphaGrades;
                res.DisplayStudentAverage    = gradeBook.Options.DisplayStudentAverage;
                res.DisplayTotalPoints       = gradeBook.Options.DisplayTotalPoints;
                res.IncludeWithdrawnStudents = gradeBook.Options.IncludeWithdrawnStudents;
                res.RoundDisplayedAverages   = gradeBook.Options.RoundDisplayedAverages;
            }
            foreach (var student in gradeBook.Students)
            {
                res.Students.Add(GradeStudentViewData.Create(student, student.IsWithdrawn));
            }
            var stIds = res.Students.Select(x => x.StudentInfo.Id).ToList();

            res.TotalAverages = StudentTotalAveragesViewData.Create(gradeBook.Averages, stIds);

            var gpAvg = res.TotalAverages.FirstOrDefault(x => x.IsGradingPeriodAverage);

            if (gpAvg != null)
            {
                res.Avg = gpAvg.TotalAverage;
            }

            if (res.DisplayTotalPoints || res.DisplayAlphaGrades)
            {
                BuildTotalPoints(res, stIds, gradeBook.StudentTotalPoints);
            }

            res.GradingItems = gradeBook.Announcements
                               .OrderByDescending(x => x.ClassAnnouncementData.Expires)
                               .Select(x => ShortAnnouncementGradeViewData.Create(x.ClassAnnouncementData, x.StudentAnnouncements, stIds, claims))
                               .ToList();

            return(res);
        }