Esempio n. 1
0
        public static StudentTotalAveragesViewData Create(IList <ChalkableStudentAverage> averages)
        {
            var res = new StudentTotalAveragesViewData
            {
                Averages = averages.Select(StudentAveragesViewData.Create).ToList(),
            };

            if (averages.Count > 0)
            {
                res.AverageId              = averages.First().AverageId;
                res.AverageName            = averages.First().AverageName;
                res.IsGradingPeriodAverage = averages.First().IsGradingPeriodAverage;
                res.TotalAverage           = averages.Average(x => (x.EnteredAvg ?? x.CalculatedAvg));
            }
            return(res);
        }
Esempio n. 2
0
        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);
        }