Example #1
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;
                    }
                }
            }
        }
Example #2
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);
            }
        }