Ejemplo n.º 1
0
        public ActionResult MiniQuizInfo(int standardId)
        {
            if (!Context.PersonId.HasValue)
            {
                throw new UnassignedUserException();
            }
            var standard    = SchoolLocator.StandardService.GetStandardById(standardId);
            var miniQuizApp = MasterLocator.ApplicationService.GetMiniQuizAppication();

            var allApps = MasterLocator.ApplicationService.GetApplications(live: true)
                          .Select(BaseApplicationViewData.Create).ToList();

            IList <Application> suggestedApps = new List <Application>();

            if (standard.AcademicBenchmarkId.HasValue)
            {
                suggestedApps = MasterLocator.ApplicationService.GetSuggestedApplications(
                    new List <Guid> {
                    standard.AcademicBenchmarkId.Value
                }, 0, int.MaxValue);
            }

            //filter banned suggestedApps
            if (!BaseSecurity.IsSysAdminOrDeveloper(Context))
            {
                suggestedApps = suggestedApps?.Where(x => allApps.Any(y => x.Id == y.Id)).ToList();
            }

            var hasMyAppDic = suggestedApps.ToDictionary(x => x.Id, x => MasterLocator.ApplicationService.HasMyApps(x));
            var userInfo    = OAuthUserIdentityInfo.Create(Context.Login, Context.Role, Context.SchoolYearId, ChalkableAuthentication.GetSessionKey());
            var token       = MasterLocator.ApplicationService.GetAccessToken(miniQuizApp.Id, ChalkableAuthentication.GetSessionKey());

            return(Json(MiniQuizAppInfoViewData.Create(miniQuizApp, suggestedApps.Select(BaseApplicationViewData.Create).ToList(), allApps,
                                                       hasMyAppDic, Context.PersonId, token)));
        }
Ejemplo n.º 2
0
        public PaginatedList <Application> GetApplicationsWithLive(Guid?developerId, ApplicationStateEnum?state, string filter, int start = 0, int count = Int32.MaxValue)
        {
            var onlyWithLive = state == ApplicationStateEnum.Live;
            var query        = new ApplicationQuery
            {
                DeveloperId = developerId,
                State       = onlyWithLive ? null : state,
                Filter      = filter,
                Ban         = !BaseSecurity.IsSysAdminOrDeveloper(Context) ? false : (bool?)null
            };

            var apps = GetApplications(query).Where(x => x.State != ApplicationStateEnum.Live).ToList();

            if (onlyWithLive)
            {
                apps = apps.Where(a => a.OriginalRef.HasValue).ToList();
            }
            var appsLiveIds = apps.Where(x => x.OriginalRef.HasValue).Select(x => x.OriginalRef.Value).ToList();

            if (appsLiveIds.Count > 0)
            {
                var liveApps = GetApplicationsByIds(appsLiveIds);
                foreach (var app in apps)
                {
                    if (app.OriginalRef.HasValue)
                    {
                        app.LiveApplication = liveApps.First(x => x.Id == app.OriginalRef);
                    }
                }
            }
            return(new PaginatedList <Application>(apps, start / count, count));
        }
Ejemplo n.º 3
0
        public PaginatedList <Application> GetApplications(int start = 0, int count = int.MaxValue, bool?live = null, bool?canAttach = null)
        {
            var query = new ApplicationQuery
            {
                Start     = start,
                Count     = count,
                Live      = live,
                CanAttach = canAttach,
                Ban       = !BaseSecurity.IsSysAdminOrDeveloper(Context) ? false : (bool?)null
            };

            return(GetApplications(query));
        }
Ejemplo n.º 4
0
        public PaginatedList <Application> GetApplications(IList <Guid> categoriesIds, IList <int> gradeLevels, string filterWords, int start = 0, int count = int.MaxValue, bool?myApps = null, bool withBanned = false)
        {
            var query = new ApplicationQuery
            {
                CategoryIds = categoriesIds,
                GradeLevels = gradeLevels,
                Filter      = filterWords,
                Start       = start,
                Count       = count,
                Ban         = !withBanned && !BaseSecurity.IsSysAdminOrDeveloper(Context) ? false : (bool?)null
            };

            return(GetApplications(query));
        }