Beispiel #1
0
        private ChalkableGradeBook BuildGradeBook(Gradebook stiGradeBook, GradingPeriod gradingPeriod,
                                                  IList <AnnouncementComplex> anns, IList <Student> students)
        {
            var gradeBook = new ChalkableGradeBook
            {
                GradingPeriod = gradingPeriod,
                Options       = ChalkableClassOptions.Create(stiGradeBook.Options),
                Averages      = stiGradeBook.StudentAverages.Select(ChalkableStudentAverage.Create).ToList(),
                Students      = students,
                Announcements = PrepareAnnouncementDetailsForGradeBook(stiGradeBook, gradingPeriod, anns, students)
            };

            if (!stiGradeBook.Options.IncludeWithdrawnStudents)
            {
                gradeBook.Students = new List <Student>();
                foreach (var student in students)
                {
                    var score = stiGradeBook.Scores.FirstOrDefault(x => x.StudentId == student.Id);
                    if (score != null && !score.Withdrawn)
                    {
                        gradeBook.Students.Add(student);
                    }
                }
            }
            return(gradeBook);
        }
Beispiel #2
0
        private ChalkableGradeBook BuildGradeBook(Gradebook stiGradeBook, GradingPeriod gradingPeriod, IList <AnnouncementComplex> anns, IList <Student> students)
        {
            var gradeBook = new ChalkableGradeBook
            {
                GradingPeriod = gradingPeriod,
                Averages      = stiGradeBook.StudentAverages.Select(ChalkableStudentAverage.Create).ToList(),
                Students      = students,
                Options       = stiGradeBook.Options != null?ChalkableClassOptions.Create(stiGradeBook.Options) : null
            };
            var includeWithdrawnStudents = gradeBook.Options != null && gradeBook.Options.IncludeWithdrawnStudents;

            //Preapred List Of Announcement Info
            Trace.WriteLine("PrepareAnnounceemntDetailsForGradeBook " + DateTime.Now.Ticks * 1.0 / TimeSpan.TicksPerSecond);
            gradeBook.Announcements = PrepareAnnounceemntDetailsForGradeBook(stiGradeBook, gradingPeriod, anns, students, includeWithdrawnStudents);

            //prepare students score
            var stiScores = stiGradeBook.Scores;

            if (!includeWithdrawnStudents)
            {
                stiScores = stiScores.Where(x => !x.Withdrawn).ToList();
            }

            if (stiScores.Any())
            {
                gradeBook.Students = gradeBook.Students.Where(s => stiScores.Any(score => score.StudentId == s.Id)).ToList();
            }

            gradeBook.Students = gradeBook.Students
                                 .OrderBy(x => x.LastName, StringComparer.OrdinalIgnoreCase)
                                 .ThenBy(x => x.FirstName, StringComparer.OrdinalIgnoreCase).ToList();

            if (stiGradeBook.StudentTotalPoints != null)
            {
                var totalPoints = stiGradeBook.StudentTotalPoints.Where(x => x.GradingPeriodId == gradingPeriod.Id).ToList();
                gradeBook.StudentTotalPoints = StudentTotalPoint.Create(totalPoints);
            }
            return(gradeBook);
        }