Exemple #1
0
        public static ScormPackageUserEvaluation CreateBy(liteModuleLink link, dtoPackageEvaluation dto, Int32 idPerson, DateTime referenceTime, Boolean isCalculated, Boolean isCreatedByPlayer)
        {
            ScormPackageUserEvaluation item = new ScormPackageUserEvaluation();

            item.IdItem            = dto.IdItem;
            item.UniqueIdItem      = dto.UniqueIdItem;
            item.IdVersion         = dto.IdVersion;
            item.UniqueIdVersion   = dto.UniqueIdVersion;
            item.IdLink            = dto.IdLink;
            item.IdSettings        = dto.IdSettings;
            item.PlaySession       = dto.PlaySession;
            item.AlreadyCompleted  = dto.AlreadyCompleted;
            item.Status            = dto.Status;
            item.Completion        = dto.Completion;
            item.IsPassed          = dto.IsPassed;
            item.IsCompleted       = dto.IsCompleted;
            item.IsCreatedByModule = (link != null);
            item.IdPerson          = idPerson;
            if (link != null)
            {
                item.IdObject     = link.SourceItem.ObjectLongID;
                item.IdObjectType = link.SourceItem.ObjectTypeID;
                item.IdModule     = link.SourceItem.ServiceID;
                item.ModuleCode   = link.SourceItem.ServiceCode;
            }
            item.IsCalculated    = isCalculated;
            item.IsCreatedByPlay = isCreatedByPlayer;
            if (isCalculated)
            {
                item.CreatedOn  = referenceTime;
                item.EndPlayOn  = referenceTime;
                item.LastUpdate = referenceTime;
            }
            else
            {
                item.CreatedOn  = referenceTime;
                item.LastUpdate = referenceTime;
            }

            item.PackageSession.ActivitiesDone   = dto.ActivitiesDone;
            item.PackageSession.CompletionStatus = dto.CompletionStatus;
            item.PackageSession.LessonStatus     = dto.LessonStatus;
            item.PackageSession.SuccessStatus    = dto.SuccessStatus;
            item.PackageSession.UserScore        = dto.UserScore;
            item.PackageSession.UserTime         = dto.UserTime;
            item.PackageSession.PlayNumber       = dto.PlayNumber;
            return(item);
        }
Exemple #2
0
        public virtual void UpdateStatisticsBy(dtoPackageEvaluation dto, DateTime referenceTime, Boolean playCompleted)
        {
            Boolean updated = false;

            if (dto.IdSettings > 0 && IdSettings != dto.IdSettings)
            {
                IdSettings = dto.IdSettings;
            }
            if (!AlreadyCompleted && dto.AlreadyCompleted)
            {
                AlreadyCompleted = dto.AlreadyCompleted;
            }
            if (playCompleted && playCompleted == IsCalculated)
            {
                if (dto.UserScore > PackageSession.UserScore)
                {
                    PackageSession.UserScore = dto.UserScore;
                }
                if (dto.UserTime > PackageSession.UserTime)
                {
                    PackageSession.UserTime = dto.UserTime;
                }
                if (dto.Completion > Completion)
                {
                    Completion = dto.Completion;
                }
                if (dto.IsPassed)
                {
                    IsPassed = dto.IsPassed;
                    if (!IsCompleted)
                    {
                        PackageSession.CompletionStatus = dto.CompletionStatus;
                        PackageSession.LessonStatus     = dto.LessonStatus;
                        PackageSession.SuccessStatus    = dto.SuccessStatus;
                        Status = dto.Status;
                    }
                }
                if (dto.IsCompleted)
                {
                    IsCompleted = dto.IsCompleted;
                    PackageSession.CompletionStatus = dto.CompletionStatus;
                    PackageSession.LessonStatus     = dto.LessonStatus;
                    PackageSession.SuccessStatus    = dto.SuccessStatus;
                    Status = dto.Status;
                }
                if (dto.ActivitiesDone > PackageSession.ActivitiesDone)
                {
                    PackageSession.ActivitiesDone = dto.ActivitiesDone;
                }
            }
            else if (!IsCalculated)
            {
                Status      = dto.Status;
                Completion  = dto.Completion;
                IsPassed    = dto.IsPassed;
                IsCompleted = dto.IsCompleted;

                IsCalculated = playCompleted;
                PackageSession.ActivitiesDone   = dto.ActivitiesDone;
                PackageSession.CompletionStatus = dto.CompletionStatus;
                PackageSession.LessonStatus     = dto.LessonStatus;
                PackageSession.SuccessStatus    = dto.SuccessStatus;
                PackageSession.UserScore        = dto.UserScore;
                PackageSession.UserTime         = dto.UserTime;
                PackageSession.PlayNumber       = dto.PlayNumber;
                LastUpdate = referenceTime;
                updated    = true;
            }
            if (playCompleted && updated)
            {
                EndPlayOn = referenceTime;
            }
        }
Exemple #3
0
        public void InitView(String playerSessionId, long idItem, long idVersion, ItemType type, long idLink, Boolean saveCompleteness, Boolean isOnModal, Boolean refreshContainer, Boolean saveStatistics)
        {
            Guid  playUniqueSessionId = Guid.NewGuid();
            Guid  workingSessionId    = UserContext.WorkSessionID;
            Int32 idUser = UserContext.CurrentUserID;

            View.IdItem    = idItem;
            View.IdLink    = idLink;
            View.IdVersion = idVersion;
            if (SessionTimeout())
            {
                idUser = Service.ScormGetPlayIdUser(playerSessionId, idItem, idVersion);
            }

            liteRepositoryItem item = Service.ItemGet(idItem);

            if (SessionTimeout() && idUser == 0)
            {
                if (item == null)
                {
                    View.DisplaySessionExpired();
                }
                else
                {
                    View.DisplayMessage(item.DisplayName, item.Extension, item.Type, Domain.PlayerClosedMessage.SessionExpired);
                }
            }
            else
            {
                liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion);
                if (version != null && version.Id != idVersion)
                {
                    View.IdVersion = version.Id;
                }
                if (item == null || version == null)
                {
                    View.DisplayUnknownItem(type);
                }
                else
                {
                    type          = item.Type;
                    View.ItemType = type;
                    switch (type)
                    {
                    case ItemType.File:
                    case ItemType.Folder:
                    case ItemType.Link:
                    case ItemType.SharedDocument:
                    case ItemType.VideoStreaming:
                        View.DisplayMessage(item.DisplayName, item.Extension, type, Domain.PlayerErrors.InvalidType);
                        break;

                    case ItemType.ScormPackage:
                    case ItemType.Multimedia:
                        List <litePlayerSettings> players = Service.PlayerGetSettings();
                        if (players == null || (version != null && !players.Any(p => p.Id == version.IdPlayer && !String.IsNullOrEmpty(p.PlayUrl) && !String.IsNullOrEmpty(p.PlayerRenderUrl) && !String.IsNullOrEmpty(p.ModalPlayerRenderUrl))))
                        {
                            View.DisplayMessage(item.DisplayName, item.Extension, item.Type, Domain.PlayerErrors.PlayerUnavailable);
                        }
                        else
                        {
                            litePlayerSettings player = players.FirstOrDefault(p => p.Id == version.IdPlayer);
                            using (NHibernate.ISession session = View.GetScormSession(player.MappingPath)){
                                lm.Comol.Modules.ScormStat.Business.ScormService service = new Modules.ScormStat.Business.ScormService(AppContext, session);
                                DateTime referenceTime = DateTime.Now;
                                lm.Comol.Core.FileRepository.Domain.dtoPackageEvaluation dto = service.EvaluatePackage_NEW(idUser, playerSessionId, item.Id, item.UniqueId, version.Id, version.UniqueIdVersion, out referenceTime);
                                if (dto != null && dto.IdItem > 0)
                                {
                                    dto.IdLink = idLink;
                                    lm.Comol.Core.FileRepository.Domain.ScormPackageUserEvaluation saved = Service.ScormSaveEvaluation(dto, idUser, referenceTime, true, true);
                                    if (saved != null)
                                    {
                                        if (saveCompleteness && saved != null && idLink > 0 && saved.ModuleCode == View.EduPathModuleCode)
                                        {
                                            View.SaveLinkEvaluation(saved);
                                            View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.PlayerClosedMessage.EvaluationSaved);
                                        }
                                        else
                                        {
                                            View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.PlayerClosedMessage.Successful);
                                        }
                                    }
                                    else
                                    {
                                        View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.PlayerClosedMessage.EvaluationNotSaved);
                                    }
                                }
                                else
                                {
                                    View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.PlayerClosedMessage.EvaluationNotSaved);
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
Exemple #4
0
        private void LoadPlayer(Int32 idUser, String playSessionId, Guid workingSessionId, liteRepositoryItem item, liteRepositoryItemVersion version, liteFileTransfer fileTransfer, liteModuleLink link, String language, Boolean saveCompleteness, Boolean isOnModal, Boolean refreshContainer, Boolean saveStatistics)
        {
            List <litePlayerSettings> players = Service.PlayerGetSettings();

            if (players == null || (version != null && !players.Any(p => p.Id == version.IdPlayer && !String.IsNullOrEmpty(p.PlayUrl) && !String.IsNullOrEmpty(p.PlayerRenderUrl) && !String.IsNullOrEmpty(p.ModalPlayerRenderUrl))))
            {
                View.DisplayMessage(item.DisplayName, item.Extension, item.Type, Domain.PlayerErrors.PlayerUnavailable);
            }
            else
            {
                String             playUrl       = "";
                String             ajaxActionUrl = "";
                litePlayerSettings player        = players.FirstOrDefault(p => p.Id == version.IdPlayer);
                Int32 idCommunity = View.ItemIdCommunity;
                Int32 idAction    = (link == null) ? (int)ModuleRepository.ActionType.PlayFile : link.Action;
                if (saveStatistics)
                {
                    Service.StatisticsAddPlay(idUser, item.Repository, version, idCommunity, (long)ModuleRepository.ActionType.PlayFile, playSessionId);
                }

                ajaxActionUrl = RootObject.AjaxAction(idCommunity, item.Id, version.UniqueIdItem, version.Id, version.UniqueIdVersion, version.Type, (link == null ? 0 : link.Id), idAction, workingSessionId, playSessionId, isOnModal);
                switch (version.Type)
                {
                case ItemType.Multimedia:
                    if (saveCompleteness && link != null)
                    {
                        View.SaveLinkEvaluation(idUser, link.Id);
                    }



                    playUrl  = player.PlayUrl.Replace("#" + PlayerPlaceHolders.defaultDocumentPath + "#", System.Web.HttpUtility.HtmlEncode(fileTransfer.DefaultDocumentPath.Replace("\\", "/")));
                    playUrl += (!playUrl.Contains("?")) ? "?" : "&";

                    playUrl += QueryKeyNames.wSessionId.ToString() + "=" + playSessionId;
                    playUrl += "&" + QueryKeyNames.idUser.ToString() + "=" + idUser.ToString();
                    if (link != null)
                    {
                        playUrl += "&" + QueryKeyNames.idLink.ToString() + "=" + link.Id.ToString();
                    }
                    playUrl += "&" + QueryKeyNames.uniqueIdVersion.ToString() + "=" + version.UniqueIdVersion.ToString();
                    if (isOnModal)
                    {
                        View.DisplayClosingToolBar();
                    }
                    break;

                case ItemType.ScormPackage:
                    Service.ScormAddPendingEvaluation(item, version, UserContext.CurrentUserID, (link == null ? 0 : link.Id));
                    if (saveStatistics)
                    {
                        using (NHibernate.ISession session = View.GetScormSession(player.MappingPath))
                        {
                            lm.Comol.Modules.ScormStat.Business.ScormService service = new Modules.ScormStat.Business.ScormService(AppContext, session);
                            DateTime referenceTime = DateTime.Now;

                            lm.Comol.Core.FileRepository.Domain.dtoPackageEvaluation dto = service.EvaluatePackage_NEW(idUser, playSessionId, item.Id, item.UniqueId, version.Id, version.UniqueIdVersion, out referenceTime);

                            if (dto != null)
                            {
                                dto.IdLink = (link == null) ? 0 : link.Id;
                                lm.Comol.Core.FileRepository.Domain.ScormPackageUserEvaluation saved = Service.ScormSaveEvaluation(dto, idUser, referenceTime, false, true);
                                if (saveCompleteness && saved != null && link != null)
                                {
                                    if (saved.ModuleCode == View.EduPathModuleCode && link.Id > 0)
                                    {
                                        View.SaveLinkEvaluation(idUser, link.Id, saved);
                                    }
                                }
                            }
                        }
                    }

                    playUrl = player.PlayUrl;
                    playUrl = playUrl.Replace("#" + PlayerPlaceHolders.idUser.ToString() + "#", idUser.ToString());
                    playUrl = playUrl.Replace("#" + PlayerPlaceHolders.courseId.ToString() + "#", version.UniqueIdVersion.ToString().Replace(" ", "%20").Replace("\\", "%2F").Replace("/", "%2F"));
                    playUrl = playUrl.Replace("#" + PlayerPlaceHolders.workingSessionId.ToString() + "#", playSessionId);
                    playUrl = playUrl.Replace("#" + PlayerPlaceHolders.dbIdentifier.ToString() + "#", player.DBidentifier);

                    if (!saveStatistics && !String.IsNullOrEmpty(player.NoSaveStatParameter))
                    {
                        playUrl += (playUrl.Contains("?") ? "&" : "?") + player.NoSaveStatParameter;
                    }
                    playUrl += RootObject.PlayBaseParameters(!saveStatistics, refreshContainer, isOnModal, saveCompleteness);
                    playUrl += RootObject.UrlItemParameters(false, version.IdItem, version.Id, (link != null ? link.Id : 0));
                    playUrl += RootObject.UrlGuidParameters(version.UniqueIdItem, version.UniqueIdVersion);

                    break;
                }
                View.InitializePlayer((isOnModal ? player.ModalPlayerRenderUrl : player.PlayerRenderUrl), playUrl, ajaxActionUrl, item.DisplayName, item.Type);
            }
        }