Esempio n. 1
0
        /// <summary>
        /// Recupera le statistiche dell'utente CORRENTE per i moocs della comunità CORRENTE.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// ToDo: usare oggetto di dominio in OUTPUT
        /// ToDo: Ottimizzare la 50.000 chiamate a roba vecchia...
        /// </remarks>
        public dtoMoocInfoResponse Get()
        {
            //dtoNoticeBoardPlainListResponse response = new dtoNoticeBoardPlainListResponse();
            //response.ErrorInfo = base.LastError;

            //ContextHelper.APIContext.
            IList <dtoEPitemList> paths    = new List <dtoEPitemList>();
            dtoMoocInfoResponse   response = new dtoMoocInfoResponse();

            response.Moocs = new List <dtoCokadeInfo>();

            COL_Persona UtenteCorrente = new COL_Persona(base.AppContext.UserContext.CurrentUserID);


            int usrId = base.AppContext.UserContext.CurrentUserID;
            int comId = base.AppContext.UserContext.CurrentCommunityID;

            try
            {
                paths = ServiceEP.GetMyEduPaths(usrId,
                                                comId,
                                                UtenteCorrente.GetIDRuoloForComunita(comId),
                                                EpViewModeType.View, true);
            }
            catch (Exception ex)
            {
                string exception = ex.ToString();
            }


            //Me.CurrentContext.UserContext.CurrentUserID, CurrentCommunityID, CurrentCommRoleID, Me.ViewModeType, PreloadIsMooc)


            foreach (dtoEPitemList path in paths)
            {
                dtoStatWithWeight statForBar = ServiceEP.ServiceStat.GetPassedCompletedWeight_byActivity(path.Id, usrId,
                                                                                                         DateTime.Now);


                lm.Comol.Modules.EduPath.Domain.DTO.dtoCokadeInfo mooc = new dtoCokadeInfo();
                mooc.CommunityId        = comId;
                mooc.PathId             = path.Id;
                mooc.PathName           = path.Name;
                mooc.Info               = new dtoCokadeMoocInfo();
                mooc.Info.Completion    = statForBar.Completion;
                mooc.Info.MinCompletion = statForBar.MinCompletion;
                mooc.Info.mType         = path.moocType;
                StatusStatistic moocStatus = ServiceStat.GetEpUserStatus(path.Id, usrId);

                mooc.Info.mookCompleted = CheckStatusStatistic(moocStatus, StatusStatistic.Completed) ||
                                          CheckStatusStatistic(moocStatus, StatusStatistic.CompletedPassed) ||
                                          CheckStatusStatistic(moocStatus, StatusStatistic.Passed);

                response.Moocs.Add(mooc);
            }

            response.IsCommunityCokade = ServiceEP.CokadeEnabled(comId);

            if (response.IsCommunityCokade)
            {
                IList <dtoCokadeInfo> MoocsType2 = response.Moocs.Where(c => c.Info.mType == MoocType.Cockade).ToList();
                response.CokadeCompleted     = MoocsType2.All(m => m.Info.mookCompleted);
                response.CokadeCompletedGold = MoocsType2.All(m => m.Info.mookCompleted && m.Info.Completion >= 100);
            }

            return(response);
        }