private dtoEvaluation EvaluateModule(DataContext dc, DataContext ic, ModuleLink link, int idUser, Dictionary <String, long> moduleUserLong, Dictionary <String, String> moduleUserString)
        {
            dtoEvaluation evaluation = null;

            if (link != null)
            {
                //iLinkedService service = null;
                //switch (link.DestinationItem.ServiceCode)
                //{
                //    case Services_EduPath.Codex:
                //        service = new lm.Comol.Modules.EduPath.BusinessLogic.Service(dc);
                //        break;
                //    case lm.Comol.Core.FileRepository.Domain.ModuleRepository.UniqueCode:
                //        service = new lm.Comol.Core.BaseModules.FileRepository.Business.ServiceRepositoryScorm(dc, ic);
                //        break;
                //    case lm.Comol.Modules.Standard.ProjectManagement.Domain.ModuleProjectManagement.UniqueCode:
                //        service = new lm.Comol.Modules.Standard.ProjectManagement.Business.ServiceProjectManagement(dc);
                //        break;
                //    case lm.Comol.Core.BaseModules.Tickets.ModuleTicket.UniqueCode:
                //        service = new lm.Comol.Core.BaseModules.Tickets.TicketService(dc);
                //        break;
                //    case COL_Questionario.Business.ServiceQuestionnaire.UniqueID:
                //        service = new COL_Questionario.Business.ServiceQuestionnaire(dc);
                //        break;
                //    default:
                //        break;
                //}
                iLinkedService service = ServiceGet(link.DestinationItem.ServiceCode, dc);
                if (service != null)
                {
                    evaluation = service.EvaluateModuleLink(link, idUser, moduleUserLong, moduleUserString);
                }
            }
            return(evaluation);
        }
        //public void SaveActionsExecution(List<dtoItemEvaluation<long>> evaluatedLinks, int UserID)
        //{
        //    if (evaluatedLinks != null && evaluatedLinks.Count > 0) {
        //        try
        //        {
        //            Manager.BeginTransaction();
        //            IList<long> IdLinks = (from e in evaluatedLinks select e.Item).ToList();
        //            IList<ModuleLink> links = (from l in Manager.GetIQ<ModuleLink>()
        //                                       where IdLinks.Contains(l.Id)
        //                                       select l).ToList();

        //            foreach (dtoItemEvaluation<long> dto in evaluatedLinks)
        //            {
        //                ModuleLink link = (from l in links where l.Id == dto.Item select l).FirstOrDefault();
        //                if (link != null)
        //                {
        //                    int croleId = Manager.GetActiveSubscriptionRoleId(UserID, link.SourceItem.CommunityID); //Manager.Get<SubActivity>(Link.SourceItem.ObjectLongID).Community.Id);

        //                    ServiceStat.InitOrUpdateSubActivityNoTransaction(link.SourceItem.ObjectLongID, UserID, croleId, UserID, "", "", dto.Completion, dto.Mark, dto.isStarted, dto.isCompleted, dto.isPassed);
        //                }
        //            }

        //            Manager.Commit();
        //        }
        //        catch (Exception ex)
        //        {
        //            Manager.RollBack();
        //            Debug.Write(ex);
        //        }
        //    }
        //}


        public void SaveActionExecution(Int32 idUser, long idLink, Boolean isStarted, Boolean isPassed, short completion, Boolean isCompleted, short mark, DateTime?referenceTime = null)
        {
            dtoEvaluation evaluation = new dtoEvaluation()
            {
                Completion = completion, isCompleted = isCompleted, isPassed = isPassed, isStarted = isStarted, Mark = mark
            };

            SaveActionExecution(idUser, idLink, evaluation, referenceTime);
        }
        public void SaveActionExecution(Int32 idUser, Int32 idRole, long idLink, dtoEvaluation evaluation, DateTime?referenceTime)
        {
            liteModuleLink link = Manager.Get <liteModuleLink>(idLink);

            if (link != null)
            {
                switch (link.SourceItem.ObjectTypeID)
                {
                case (int)ModuleEduPath.ObjectType.SubActivity:
                    SaveActionExecution(idUser, idRole, GetPathId_BySubActivityId(link.SourceItem.ObjectLongID), link.SourceItem.ObjectLongID, evaluation, referenceTime);
                    break;
                }
            }
        }
Пример #4
0
        //Effettivamente utilizzati
        public dtoEvaluation EvaluateModuleLink(ModuleLink link, Int32 idUser, Dictionary <String, long> moduleUserLong = null, Dictionary <String, String> moduleUserString = null)
        {
            //if (Link.SourceItem.ObjectTypeID == ??)

            Int64 FileId = link.SourceItem.ObjectLongID;

            IList <Int64> FilesIds = new List <Int64>();

            FilesIds.Add(FileId);

            IList <int> UsersIds = new List <int>();

            UsersIds.Add(idUser);

            IList <ColFile> ColFiles = this.ColScormManager.GetStatFileUser(FilesIds, UsersIds);


            dtoEvaluation EvalML = new dtoEvaluation();

            if (ColFiles.Count > 0)
            {
                ColFile File = ColFiles[0];
                //Stat.Status
                switch (File.UserStats[0].Status)
                {
                case lm.Comol.Modules.ScormStat.Icodeon.StatusCode.Completed:
                    EvalML.isStarted   = true;
                    EvalML.isCompleted = true;
                    EvalML.isPassed    = true;
                    break;

                case lm.Comol.Modules.ScormStat.Icodeon.StatusCode.Started:
                    EvalML.isStarted   = true;
                    EvalML.isCompleted = false;
                    EvalML.isPassed    = false;
                    break;

                default:
                    EvalML.isStarted   = false;
                    EvalML.isCompleted = false;
                    EvalML.isPassed    = false;
                    break;
                }

                EvalML.Completion = (short)((File.UserStats[0].NumActivity / File.Package.ActivityCount) * 100);
            }

            return(EvalML);
        }
        public void UpdateEvaluation()
        {
            int  IdUser = UserContext.CurrentUserID;
            long IdFile = View.FileId;

            if (!UserContext.isAnonymous)
            {
                dtoEvaluation            evaluation = View.GetScormEvaluation(IdUser, IdFile);
                List <dtoEvaluationLink> links      = GetRelatedLinks(IdUser, IdFile);
                if (evaluation != null && links.Count > 0)
                {
                    View.EvaluateLinks(IdUser, (from l in links select l.LinkId).ToList(), evaluation);
                    RemoveUpdateActions(IdUser, links);
                }
            }
        }
        /// <summary>
        /// Get evaluation of link
        /// </summary>
        /// <param name="idLink"></param>
        /// <param name="idUser"></param>
        /// <param name="moduleUserLong"></param>
        /// <param name="moduleUserString"></param>
        /// <returns></returns>
        public dtoEvaluation EvaluateModuleLinkForExternal(long idLink, int idUser, Dictionary <String, long> moduleUserLong, Dictionary <String, String> moduleUserString)
        {
            dtoEvaluation evaluation = null;

            using (ISession session = NHSessionHelper.GetComolSession())
            {
                DataContext dc   = new DataContext(session);
                ModuleLink  link = dc.GetById <ModuleLink>(idLink);
                using (ISession icodeon = NHSessionHelper.GetIcodeonSession())
                {
                    DataContext ic = new DataContext(icodeon);
                    evaluation = EvaluateModule(dc, ic, link, idUser, moduleUserLong, moduleUserString);
                }
            }
            return(evaluation);
        }
        public void SaveActionExecution(Int32 idUser, long idLink, dtoEvaluation evaluation, DateTime?referenceTime = null)
        {
            liteModuleLink link = Manager.Get <liteModuleLink>(idLink);

            if (link != null)
            {
                switch (link.SourceItem.ObjectTypeID)
                {
                case (int)ModuleEduPath.ObjectType.SubActivity:
                    long  idPath      = GetPathId_BySubActivityId(link.SourceItem.ObjectLongID);
                    Int32 idCommunity = GetPathIdCommunity(idPath);
                    Int32 idRole      = Manager.GetActiveSubscriptionIdRole(idUser, idCommunity);
                    SaveActionExecution(idUser, idRole, idPath, link.SourceItem.ObjectLongID, evaluation, referenceTime);
                    break;
                }
            }
        }
Пример #8
0
        public dtoEvaluation EvaluateModuleLink(ModuleLink link, int idUser, Dictionary <string, long> moduleUserLong = null, Dictionary <string, string> moduleUserString = null)
        {
            dtoEvaluation result = new dtoEvaluation();

            return(result);
        }
Пример #9
0
        public void SaveActionExecution(
            Int32 idUser,
            Int32 idRole,
            long idPath,
            long idSubActivity,
            dtoEvaluation evaluation,
            DateTime?referenceTime)
        {
            try
            {
                Boolean        save     = true;
                Path           path     = GetPath(idPath);
                PolicySettings settings = null;
                if (path != null)
                {
                    settings = path.Policy;
                }

                if (settings != null)
                {
                    switch (settings.Statistics)
                    {
                    case CompletionPolicy.UpdateAlways:
                        break;

                    default:
                        List <SubActivityStatistic> items = GetUserStatistics(idSubActivity, idUser, ((referenceTime != null && referenceTime.HasValue) ? referenceTime.Value : DateTime.Now));
                        SubActivityStatistic        last  = (items == null ? null : items.FirstOrDefault());
                        switch (settings.Statistics)
                        {
                        case CompletionPolicy.NoUpdateIfCompleted:
                            if (evaluation.isPassed && evaluation.isCompleted)
                            {
                                save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed));
                            }
                            else
                            {
                                save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.Completed) || ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed));
                            }
                            break;
                            //case CompletionPolicy.UpdateOnlyIfBetter:
                            //    if (last != null)
                            //        save = (last.Completion < evaluation.Completion || (
                            //                 ((!ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.Completed) && !ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.CompletedPassed))
                            //                 && (evaluation.Status == Core.FileRepository.Domain.PackageStatus.completed
                            //                     || evaluation.Status == Core.FileRepository.Domain.PackageStatus.completedpassed))
                            //                     ));

                            //    break;
                            //case CompletionPolicy.UpdateOnlyIfWorst:
                            //    break;
                        }
                        break;
                    }
                }
                if (save)
                {
                    Manager.BeginTransaction();
                    ServiceStat.InitOrUpdateSubActivityNoTransaction(idSubActivity, idUser, idRole, idUser, UC.IpAddress, UC.ProxyIpAddress, evaluation.Completion, (short)evaluation.Completion, evaluation.isStarted, evaluation.isCompleted, evaluation.isPassed);
                    Manager.Commit();
                }
            }
            catch (Exception ex)
            {
            }
        }