예제 #1
0
        public FeedSettingsInfo GetSettingsForFeed()
        {
            Trace.Assert(Context.PersonId.HasValue);
            Trace.Assert(Context.SchoolYearId.HasValue);

            var query = new List <string>
            {
                PersonSetting.FEED_START_DATE,
                PersonSetting.FEED_END_DATE,
                PersonSetting.FEED_ANNOUNCEMENT_TYPE,
                PersonSetting.FEED_SORTING,
                PersonSetting.FEED_GRADING_PERIOD_ID
            };
            var settings = ServiceLocator.PersonSettingService.GetSettingsForPerson(Context.PersonId.Value, Context.SchoolYearId.Value, query);
            var res      = new FeedSettingsInfo(settings);

            if (res.GradingPeriodId.HasValue)
            {
                var gp = ServiceLocator.GradingPeriodService.GetGradingPeriodById(res.GradingPeriodId.Value);
                res.FromDate = gp.StartDate;
                res.ToDate   = gp.EndDate;
            }
            else if (res.AnyDate)
            {
                res.FromDate = Context.SchoolYearStartDate;
                res.ToDate   = Context.SchoolYearEndDate;
            }
            return(res);
        }
예제 #2
0
 public static FeedComplexViewData PrepareFeedComplexViewData(IServiceLocatorSchool schoolL, IList <AnnouncementComplex> announcements
                                                              , FeedSettingsInfo settings, IList <AnnouncementComplex> createdAnnouncements)
 {
     return(new FeedComplexViewData
     {
         AnnoucementViewDatas = PrepareAnnouncementsComplexViewData(schoolL, announcements),
         CreatedAnnouncements = PrepareAnnouncementsComplexViewData(schoolL, createdAnnouncements ?? new List <AnnouncementComplex>()),
         SettingsForFeed = FeedSettingsViewData.Create(settings)
     });
 }
예제 #3
0
 public static FeedSettingsViewData Create(FeedSettingsInfo feedSett)
 {
     return(new FeedSettingsViewData
     {
         AnnouncementType = feedSett.AnnouncementType,
         FromDate = feedSett.GradingPeriodId.HasValue || feedSett.AnyDate ? null : feedSett.FromDate,
         GradingPeriodId = feedSett.GradingPeriodId,
         SortType = feedSett.SortType,
         ToDate = feedSett.GradingPeriodId.HasValue || feedSett.AnyDate ? null : feedSett.ToDate,
     });
 }
예제 #4
0
        public static FeedReportViewData Create(FeedReportSettingsInfo feedReportSettings,
                                                FeedSettingsInfo feedSettingsInfo)
        {
            var res = new FeedReportViewData();

            if (!feedReportSettings.StartDate.HasValue)
            {
                res.StartDate = feedSettingsInfo.FromDate.Value;
            }

            return(res);
        }
        public static FeedReportSettingsViewData Create(FeedReportSettingsInfo feedReportSettings,
                                                        FeedSettingsInfo feedSettings)
        {
            var res = new FeedReportSettingsViewData
            {
                AnnouncementType        = feedSettings.AnnouncementType,
                EditableLpOption        = !feedSettings.AnnouncementType.HasValue,
                IncludeAttachments      = feedReportSettings.IncludeAttachments,
                IncludeDetails          = feedReportSettings.IncludeDetails,
                IncludeHiddenActivities = feedReportSettings.IncludeHiddenActivities,
                IncludeHiddenAttributes = feedReportSettings.IncludeHiddenAttributes,
                MinDate          = feedSettings.FromDate ?? DateTime.MinValue,
                MaxDate          = feedSettings.ToDate ?? DateTime.MaxValue,
                GroupByStandards = feedReportSettings.GroupByStandards
            };

            res.LessonPlanOnly = feedSettings.AnnouncementType.HasValue && (AnnouncementTypeEnum)feedSettings.AnnouncementType.Value == AnnouncementTypeEnum.LessonPlan;
            res.StartDate      = res.MinDate;
            res.EndDate        = res.MaxDate;
            return(res);
        }
예제 #6
0
        public override object PrepareDataSource(FeedReportInputModel inputModel, ReportingFormat format, IServiceLocatorSchool serviceLocator, IServiceLocatorMaster masterLocator)
        {
            var baseData = PrepareBaseReportData(inputModel, serviceLocator);

            var feedSettings = new FeedSettingsInfo
            {
                AnnouncementType = inputModel.Settings.LessonPlanOnly ? (int)AnnouncementTypeEnum.LessonPlan : inputModel.AnnouncementType,
                FromDate         = inputModel.Settings.StartDate,
                ToDate           = inputModel.Settings.EndDate
            };

            //bool isForAdminPortal = BaseSecurity.IsDistrictAdmin(serviceLocator.Context) && !inputModel.ClassId.HasValue;

            //var anns = isForAdminPortal
            //    ? serviceLocator.AnnouncementFetchService.GetAnnouncementsForAdminFeed(inputModel.Complete, null, feedSettings)
            //    : serviceLocator.AnnouncementFetchService.GetAnnouncementsForFeed(inputModel.Complete, inputModel.ClassId, feedSettings);

            var anns = serviceLocator.AnnouncementFetchService.GetAnnouncementDetailses(feedSettings.FromDate, feedSettings.ToDate, inputModel.ClassId, inputModel.Complete, feedSettings.AnnouncementTypeEnum);

            //hide hidden activities
            if (!inputModel.Settings.IncludeHiddenActivities)
            {
                anns = anns.Where(x => x.ClassAnnouncementData == null || x.ClassAnnouncementData.VisibleForStudent).ToList();
            }

            ////remove standards if groupByStandards is not selected
            //if (!inputModel.Settings.GroupByStandards)
            //    anns = anns.Select(x =>
            //    {
            //        x.AnnouncementStandards = new List<AnnouncementStandardDetails>();
            //        return x;
            //    }).ToList();

            var fromDate = inputModel.Settings.StartDate ?? serviceLocator.Context.SchoolYearStartDate;
            var toDate   = inputModel.Settings.EndDate ?? serviceLocator.Context.SchoolYearEndDate;

            return(ShortFeedExportModel.Create(baseData.Person, baseData.SchoolName, baseData.SchoolYearName, serviceLocator.Context.NowSchoolTime,
                                               fromDate, toDate, baseData.Classes, baseData.Staffs, baseData.DayTypes, anns, inputModel.Settings.GroupByStandards));
        }
예제 #7
0
        public IList <AnnouncementComplex> GetAnnouncementsForFeed(bool?complete, int?classId, FeedSettingsInfo settings, int start = 0, int count = int.MaxValue)
        {
            var feedStartDate = settings.FromDate ?? DateTime.MinValue;
            var feedEndDate   = settings.ToDate ?? DateTime.MaxValue;
            var sortOption    = settings.SortTypeEnum ?? AnnouncementSortOption.DueDateAscending;
            var ownedOnly     = !classId.HasValue ? (bool?)true : null;

            if (!settings.AnnouncementTypeEnum.HasValue)
            {
                return(_handlers[sortOption].GetAllItems(ServiceLocator, feedStartDate, feedEndDate, classId, complete, start, count, ownedOnly));
            }

            switch (settings.AnnouncementTypeEnum.Value)
            {
            case AnnouncementTypeEnum.Class:
                return(ServiceLocator.ClassAnnouncementService.GetClassAnnouncementsForFeed(feedStartDate, feedEndDate, classId, complete, null, start, count, sortOption));

            case AnnouncementTypeEnum.LessonPlan:
                return(_handlers[sortOption].GetLessonPlansOnly(ServiceLocator, feedStartDate, feedEndDate, classId, complete, start, count, ownedOnly));

            case AnnouncementTypeEnum.Admin:
                return(classId.HasValue ? new List <AnnouncementComplex>() : _handlers[sortOption].GetAdminAnnouncementsOnly(ServiceLocator, feedStartDate, feedEndDate, null, complete, start, count));

            case AnnouncementTypeEnum.Supplemental:
                return(_handlers[sortOption].GetSupplementalAnnouncementsOnly(ServiceLocator, feedStartDate, feedEndDate, classId, complete, start, count, true));
            }
            return(new List <AnnouncementComplex>());
        }
예제 #8
0
        public IList <AnnouncementComplex> GetAnnouncementsForAdminFeed(bool?complete, IList <int> gradeLevels, FeedSettingsInfo settings, int start = 0, int count = int.MaxValue)
        {
            var feedStartDate = settings.FromDate ?? DateTime.MinValue;
            var feedEndDate   = settings.ToDate ?? DateTime.MaxValue;
            var sortOption    = settings.SortTypeEnum ?? AnnouncementSortOption.DueDateAscending;

            return(_handlers[sortOption].GetAdminAnnouncementsOnly(ServiceLocator, feedStartDate, feedEndDate, gradeLevels, complete, start, count));
        }
예제 #9
0
 public void SetSettingsForFeed(FeedSettingsInfo settings)
 {
     Trace.Assert(Context.PersonId.HasValue);
     Trace.Assert(Context.SchoolYearId.HasValue);
     ServiceLocator.PersonSettingService.SetSettingsForPerson(Context.PersonId.Value, Context.SchoolYearId.Value, settings.ToDictionary());
 }
예제 #10
0
        public static FeedComplexViewData GetAnnouncementForFeedList(IServiceLocatorSchool schoolL, int?start, int?count
                                                                     , bool?complete, int?classId, FeedSettingsInfo settings, IList <AnnouncementInputModel> createdAnnouncements)
        {
            start = start ?? 0;
            count = count ?? (DemoUserService.IsDemoUser(schoolL.Context) ? int.MaxValue : 10);

            var list = schoolL.AnnouncementFetchService.GetAnnouncementsForFeed(complete, classId, settings, start.Value, count.Value);
            List <AnnouncementComplex> createdAnns = new List <AnnouncementComplex>();

            if (createdAnnouncements != null)
            {
                var lpIds = createdAnnouncements.Where(x => x.AnnouncementType == (int)AnnouncementTypeEnum.LessonPlan)
                            .Select(x => x.AnnouncementId).ToList();
                var clAnnIds = createdAnnouncements.Where(x => x.AnnouncementType == (int)AnnouncementTypeEnum.Class)
                               .Select(x => x.AnnouncementId).ToList();
                var suppAnnIds = createdAnnouncements.Where(x => x.AnnouncementType == (int)AnnouncementTypeEnum.Supplemental)
                                 .Select(x => x.AnnouncementId).ToList();

                if (clAnnIds.Count > 0)
                {
                    createdAnns.AddRange(schoolL.ClassAnnouncementService.GetAnnouncementsByIds(clAnnIds));
                }
                if (lpIds.Count > 0)
                {
                    createdAnns.AddRange(schoolL.LessonPlanService.GetAnnouncementsByIds(lpIds));
                }
                if (suppAnnIds.Count > 0)
                {
                    createdAnns.AddRange(schoolL.SupplementalAnnouncementService.GetAnnouncementsByIds(suppAnnIds));
                }
            }
            return(PrepareFeedComplexViewData(schoolL, list, settings, createdAnns));
        }
예제 #11
0
 public ActionResult SetSettings(FeedSettingsInfo settings)
 {
     SchoolLocator.AnnouncementFetchService.SetSettingsForFeed(settings);
     return(Json(true));
 }
예제 #12
0
 public ActionResult ClassFeed(int classId, int?start, int?count, bool?complete, FeedSettingsInfo settings, IList <AnnouncementInputModel> createdAnnouncements)
 {
     //settings = SchoolLocator.AnnouncementFetchService.GetSettingsForClassFeed(classId);
     return(Json(GetAnnouncementForFeedList(SchoolLocator, start, count, complete, classId, settings, createdAnnouncements)));
 }