public static StudentAnnouncementViewData Create(StudentAnnouncementDetails studentAnnouncement, IList <AnnouncementAttachmentInfo> attachments)
 {
     return(new StudentAnnouncementViewData(studentAnnouncement)
     {
         StudentInfo = StudentViewData.Create(studentAnnouncement.Student),
         Attachments = attachments.Select(x => AnnouncementAttachmentViewData.Create(x, true)).ToList(),
     });
 }
示例#2
0
        private IList <AnnouncementDetails> PrepareAnnounceemntDetailsForGradeBook(Gradebook stiGradeBook, GradingPeriod gradingPeriod
                                                                                   , IList <AnnouncementComplex> anns, IList <Student> students, bool inludeWithdrawnStudent)
        {
            var activities = stiGradeBook.Activities.Where(x => x.Date >= gradingPeriod.StartDate &&
                                                           x.Date <= gradingPeriod.EndDate && x.IsScored).ToList();
            var annsDetails     = new List <AnnouncementDetails>();
            var classTeachers   = ServiceLocator.ClassService.GetClassTeachers(stiGradeBook.SectionId, null);
            var alternateScores = ServiceLocator.AlternateScoreService.GetAlternateScores();

            foreach (var activity in activities)
            {
                var ann = anns.FirstOrDefault(x => x.ClassAnnouncementData.SisActivityId == activity.Id);
                if (ann == null)
                {
                    throw new ChalkableException(string.Format("No announcements with sis activity id = {0}", activity.Id));
                }
                var annDetails = new AnnouncementDetails
                {
                    Id = ann.Id,
                    AnnouncementData     = ann.ClassAnnouncementData,
                    Title                = ann.Title,
                    StudentAnnouncements = new List <StudentAnnouncementDetails>(),
                    IsOwner              = classTeachers.Any(x => x.PersonRef == Context.PersonId)
                };
                MapperFactory.GetMapper <AnnouncementDetails, Activity>().Map(annDetails, activity);
                var scores = stiGradeBook.Scores.Where(x => x.ActivityId == activity.Id).ToList();
                if (!inludeWithdrawnStudent)
                {
                    scores = scores.Where(x => !x.Withdrawn).ToList();
                }
                foreach (var score in scores)
                {
                    var student = students.FirstOrDefault(x => x.Id == score.StudentId);
                    if (student == null)
                    {
                        continue;
                    }
                    var stAnn = new StudentAnnouncementDetails
                    {
                        AnnouncementId = ann.Id,
                        ClassId        = ann.ClassAnnouncementData.ClassRef,
                        Student        = student,
                    };
                    MapperFactory.GetMapper <StudentAnnouncementDetails, Score>().Map(stAnn, score);
                    if (stAnn.AlternateScoreId.HasValue)
                    {
                        stAnn.AlternateScore = alternateScores.FirstOrDefault(x => x.Id == stAnn.AlternateScoreId.Value);
                    }
                    annDetails.StudentAnnouncements.Add(stAnn);
                }
                annDetails.StudentAnnouncements = annDetails.StudentAnnouncements.OrderBy(x => x.Student.LastName).ThenBy(x => x.Student.FirstName).ToList();
                annsDetails.Add(annDetails);
            }
            return(annsDetails);
        }
示例#3
0
        private StudentAnnouncementDetails CreateStudentAnnouncement(ClassAnnouncement ann, Student student, Score score, IList <AlternateScore> alternateScores)
        {
            var stAnn = new StudentAnnouncementDetails
            {
                ClassId        = ann.ClassRef,
                Student        = student,
                AnnouncementId = ann.Id
            };

            MapperFactory.GetMapper <StudentAnnouncementDetails, Score>().Map(stAnn, score);
            if (stAnn.AlternateScoreId.HasValue)
            {
                stAnn.AlternateScore = alternateScores.FirstOrDefault(x => x.Id == stAnn.AlternateScoreId.Value);
            }
            return(stAnn);
        }
示例#4
0
        private IList <AnnouncementDetails> PrepareAnnouncementDetailsForGradeBook(Gradebook stiGradeBook, GradingPeriod gradingPeriod
                                                                                   , IList <AnnouncementComplex> anns, IList <Student> students)
        {
            var activities = stiGradeBook.Activities.Where(x => x.Date >= gradingPeriod.StartDate &&
                                                           x.Date <= gradingPeriod.EndDate && x.IsScored).ToList();
            var annsDetails   = new List <AnnouncementDetails>();
            var classTeachers = ServiceLocator.ClassService.GetClassTeachers(stiGradeBook.SectionId, null);

            foreach (var activity in activities)
            {
                var ann        = anns.FirstOrDefault(x => x.ClassAnnouncementData.SisActivityId == activity.Id);
                var annDetails = new AnnouncementDetails
                {
                    Id                   = ann.Id,
                    Title                = ann.Title,
                    AnnouncementData     = ann.ClassAnnouncementData,
                    StudentAnnouncements = new List <StudentAnnouncementDetails>(),
                    IsOwner              = classTeachers.Any(x => x.PersonRef == Context.PersonId)
                };
                MapperFactory.GetMapper <AnnouncementDetails, Activity>().Map(annDetails, activity);
                var scores = stiGradeBook.Scores.Where(x => x.ActivityId == activity.Id).ToList();
                if (!stiGradeBook.Options.IncludeWithdrawnStudents)
                {
                    scores = scores.Where(x => !x.Withdrawn).ToList();
                }
                foreach (var score in scores)
                {
                    var student = students.FirstOrDefault(x => x.Id == score.StudentId);
                    if (student == null)
                    {
                        continue;
                    }
                    var stAnn = new StudentAnnouncementDetails
                    {
                        AnnouncementId = ann.Id,
                        ClassId        = ann.ClassAnnouncementData.ClassRef,
                        Student        = student,
                    };
                    MapperFactory.GetMapper <StudentAnnouncementDetails, Score>().Map(stAnn, score);
                    annDetails.StudentAnnouncements.Add(stAnn);
                }
                annsDetails.Add(annDetails);
            }
            return(annsDetails);
        }
示例#5
0
        //TODO : needs testing


        public async Task <IList <StudentAnnouncementDetails> > GetStudentAnnouncementsForGradingPeriod(int schoolYearId, int studentId, int gradingPeriodId)
        {
            var gradingDetailsDashboardTask = ConnectorLocator.GradingConnector.GetStudentGradingDetails(schoolYearId, studentId, gradingPeriodId);
            var student = ServiceLocator.StudentService.GetById(studentId, schoolYearId);
            var scores  = (await gradingDetailsDashboardTask).Scores;

            var mapper = MapperFactory.GetMapper <StudentAnnouncement, Score>();
            var res    = new List <StudentAnnouncementDetails>();

            foreach (var score in scores)
            {
                var studentAnn = new StudentAnnouncementDetails
                {
                    Student   = student,
                    StudentId = studentId
                };
                mapper.Map(studentAnn, score);
                res.Add(studentAnn);
            }
            return(res);
        }
示例#6
0
        public IList <StudentAnnouncementDetails> GetStudentAnnouncements(int announcementId)
        {
            Trace.Assert(Context.PersonId.HasValue);
            Trace.Assert(Context.SchoolYearId.HasValue);
            var ann = ServiceLocator.ClassAnnouncementService.GetClassAnnouncemenById(announcementId);
            var mp  = ServiceLocator.MarkingPeriodService.GetMarkingPeriodByDate(ann.Expires, true);

            Trace.Assert(mp != null);
            if (ann.SisActivityId.HasValue)
            {
                IList <Score>   scores  = new List <Score>();
                IList <Student> persons = new List <Student>();
                if (CoreRoles.STUDENT_ROLE == Context.Role)
                {
                    scores.Add(ActivityScoreStorage.GetScore(ann.SisActivityId.Value, Context.PersonId.Value));
                    persons.Add(ServiceLocator.StudentService.GetById(Context.PersonId.Value, Context.SchoolYearId.Value));
                }
                else
                {
                    scores  = ActivityScoreStorage.GetSores(ann.SisActivityId.Value);
                    persons = ServiceLocator.StudentService.GetClassStudents(ann.ClassRef, mp.Id);
                }
                var res = new List <StudentAnnouncementDetails>();
                foreach (var score in scores)
                {
                    var stAnn = new StudentAnnouncementDetails
                    {
                        ClassId        = ann.ClassRef,
                        Student        = persons.First(x => x.Id == score.StudentId),
                        AnnouncementId = ann.Id
                    };
                    MapperFactory.GetMapper <StudentAnnouncementDetails, Score>().Map(stAnn, score);
                    res.Add(stAnn);
                }
                return(res);
            }
            throw new ChalkableException("Current announcement is not in Inow ");
        }