public static void PopulateSessionVariables(Learner learner, ContentModuleSession session, Course assignment) { LMSSession.AddSessionItem(CommonKeys.SESSION_LOGEDUSERNAME, learner.UserName); LMSSession.AddSessionItem(ContentKeys.SESSION_USER_LAST_FIRST_NAME, learner.LastName + ", " + learner.FirstName); //LMSSession.AddSessionItem(Client.CLIENT_SESSION_ID, learner.ClientId); LMSSession.AddSessionItem(ContentKeys.SESSION_LEARNER_ID, session.SystemUserGuid); LMSSession.AddSessionItem(ContentKeys.SESSION_USERNAMEALIAS, learner.UserName); // LMSSession.AddSessionItem(ContentKeys.SESSION_LERNER_LANGUAGE_ID, learner.DefaultLanguageId); //LMSSession.AddSessionItem(ContentKeys.SESSION_RVSETTINGS, learner.RegionViewName); LMSSession.AddSessionItem(ContentKeys.SESSION_RET_TOSERVER_URL, session.ReturnUrl); LMSSession.AddSessionItem(ContentKeys.SESSION_ISREVIEW, session.IsReview); LMSSession.AddSessionItem(ContentKeys.SESSION_IS_FOR_ADMIN_PREVIEW, (session.LaunchSite == LaunchSite.Admin)); LMSSession.AddSessionItem(CommonManager.IS_SSO_LOGIN, session.SsoLogin); LMSSession.AddSessionItem(ContentKeys.SESSION_IS_SAME_WINDOW, session.SameWindow); if (session.GridPageSize.HasValue) { LMSSession.AddSessionItem(CommonManager.SESSION_GRID_PAGE_SIZE, session.GridPageSize.Value); } if (session.Attempt.HasValue) { LMSSession.AddSessionItem(ContentKeys.SESSION_ATTEMPT_ID, assignment.ActivityId + "-" + learner.EmployeeId + "-" + session.Attempt.Value); } LMSSession.AddSessionItem(ContentKeys.SESSION_ACTIVITYID, assignment.ActivityId); LMSSession.AddSessionItem(ContentKeys.SESSION_COURSENAME, assignment.ContentModuleName); LMSSession.AddSessionItem(ContentKeys.SESSION_ACTIVITY_ISAUTH, true); }
/// <summary> /// This method return page elements text. /// </summary> /// <param name="entListPageElements">List<UserPageElementLanguage> entListPageElements</param> /// <param name="string">pElementName</param> /// <returns>string</returns> /// //public static string GetPageElementsText(List<UserPageElementLanguage> entListPageElements, string pElementName) //{ // string strElementText = string.Empty; // UserPageElementLanguage entElementSearch = new UserPageElementLanguage(); // entElementSearch.ElementName = pElementName; // UserPageElementLanguage entElementReturn = entListPageElements.Find(delegate(UserPageElementLanguage entElement) // { return entElement.ElementName == entElementSearch.ElementName; }); // if (entElementReturn != null) // { // strElementText = entElementReturn.ElementText; // } // return strElementText; //} #endregion ////#region GetPageElements /////// <summary> /////// This method return user page elements. /////// </summary> /////// <param name="pClientId"></param> /////// <param name="pPageId"></param> /////// <param name="pLangId"></param> /////// <returns>string</returns> /////// ////public static List<UserPageElementLanguage> GetPageElements(string pClientId, string pPageId, string pLangId) ////{ //// List<UserPageElementLanguage> entListPageElements = new List<UserPageElementLanguage>(); //// UserPage entPage = new UserPage(); //// UserPageManager mgrUserPage = new UserPageManager(); //// entPage.ClientId = pClientId; //// entPage.ID = pPageId; //// entPage.ParaLanguageId = pLangId; //// entPage = mgrUserPage.Execute(entPage, UserPage.Method.Get); //// entListPageElements = entPage.PageElementLanguage; //// return entListPageElements; ////} ////#endregion ////#region GetLearnerLanguage /////// <summary> /////// This method return current Learner language. /////// </summary> /////// <returns>string</returns> /////// ////public static string GetLearnerLanguage(Client entClient) ////{ //// string _strDefaultLanguage = string.Empty; //// string _strLearnerId = string.Empty; //// //Check for Learner Id in session //// if (LMSSession.IsInSession(Learner.USER_SESSION_ID)) //// { //// try //// { //// _strLearnerId = (string)LMSSession.GetValue(Learner.USER_SESSION_ID); //// _strDefaultLanguage = CommonManager.GetLearnerDefaultLanguage(_strLearnerId); //// } //// catch //// { //// Learner entInnerlearner = (Learner)LMSSession.GetValue(Learner.USER_SESSION_ID); //// if (entInnerlearner != null) //// _strLearnerId = entInnerlearner.ID; //// _strDefaultLanguage = CommonManager.GetLearnerDefaultLanguage(_strLearnerId); //// } //// } //// else //Get Clients Language //// { //// if (LMSSession.IsInSession(CommonManager.SESSION_MYCULTURE)) //// { //// _strDefaultLanguage = Convert.ToString(LMSSession.GetValue(CommonManager.SESSION_MYCULTURE)); //// } //// else //// { //// //Check client cookie is present //// string strClientID = entClient.ID; //// if (LMSCookie.CheckCookie(strClientID)) //// { //// _strDefaultLanguage = LMSCookie.GetCookieParam(strClientID, CommonManager.COOKIES_LANG); //// LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, _strDefaultLanguage); //// } //// else //Create client cookie and set its value //// { //// LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, entClient.DefaultLanguageId); //// _strDefaultLanguage = entClient.DefaultLanguageId; //// } //// } //// } //// string strLangTextDirection = CommonManager.LANGUAGE_TEXT_DIRECTION_LTR; //// if (!String.IsNullOrEmpty(entClient.Language.TextDirection)) //// strLangTextDirection = entClient.Language.TextDirection; //// LMSSession.AddSessionItem(CommonManager.SESSION_LANG_TEXTDIRC, strLangTextDirection); //// entClient = null; //// return _strDefaultLanguage; ////} ////#endregion ////public static string GetLearnerDefaultLanguage(string strLearnerId) ////{ //// string _strDefaultLanguage = string.Empty; //// //Get Learner Language is in Cookie //// if (LMSCookie.CheckCookie(strLearnerId)) //// { //// _strDefaultLanguage = LMSCookie.GetCookieParam(strLearnerId, CommonManager.COOKIES_LANG); //// LMSSession.AddSessionItem(CommonManager.SESSION_LEARNER_CULTURE, _strDefaultLanguage); //// LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, _strDefaultLanguage); //// } //// else //// { //// //Get Learner Language in Session //// if (LMSSession.IsInSession(CommonManager.SESSION_LEARNER_CULTURE)) //// { //// _strDefaultLanguage = Convert.ToString(LMSSession.GetValue(CommonManager.SESSION_LEARNER_CULTURE)); //// LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, _strDefaultLanguage); //// } //// else //// { //// //Get Learner Language from Database //// Learner entLearner = new Learner(); //// entLearner = CommonManager.GetLearnerById(strLearnerId); //// if (entLearner != null && !string.IsNullOrEmpty(entLearner.DefaultLanguageId)) //// { //// _strDefaultLanguage = entLearner.DefaultLanguageId; //// } //// else //// { //// Client _entClient = new Client(); //// _entClient = CommonManager.GetClient(); //// _strDefaultLanguage = _entClient.DefaultLanguageId; //// } //// LMSSession.AddSessionItem(CommonManager.SESSION_LEARNER_CULTURE, _strDefaultLanguage); //// LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, _strDefaultLanguage); //// LMSCookie.CreateUserCookies(strLearnerId); //// LMSCookie.SetCookieParam(strLearnerId, CommonManager.COOKIES_LANG, _strDefaultLanguage); //// } //// } //// return _strDefaultLanguage; ////} #region GetLearnerById /// <summary> /// Get Learner /// </summary> /// <param name="pstrUserId"></param> /// <returns>Learner</returns> public static Learner GetLearnerById(string pstrUserId) { Learner entLearner = new Learner(); if (LMSSession.IsInSession(CommonManager.SESSION_LEARNER)) { entLearner = (Learner)LMSSession.GetValue(CommonManager.SESSION_LEARNER); } else { LearnerManager mgrLearner = new LearnerManager(); entLearner.ID = pstrUserId; entLearner = mgrLearner.Execute(entLearner, Learner.Method.Get); //Add learner into session LMSSession.AddSessionItem(CommonManager.SESSION_LEARNER, entLearner); } return(entLearner); }
/// <summary> /// Page Load event call of the page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { //if (String.IsNullOrEmpty(Request["clientId"]) || String.IsNullOrEmpty(Request["sessionId"])) if (String.IsNullOrEmpty(Request["sessionId"])) { Response.Redirect("DisplayError.aspx?error=SessionTimeout"); } //~ var sClientId = CommonManager.DecodeAndDecrypt(Request["clientId"]); var sClientId = "HRS"; var sessionId = Request["sessionId"]; var contentmoduleid = Request["contentmoduleid"]; var learnerid = Request["learnerid"]; //Session["contentmoduleid"] = Request["contentmoduleid"]; var session = ContentModuleSessionRepository.GetByIdForCourseLaunch(learnerid, contentmoduleid); //var session = new ContentModuleSession(); //if (session == null) //{ // Response.Redirect("DisplayError.aspx?error=SessionTimeout"); //} string sLearnerUserNameAlias = session.Learner.UserName; //string sManagerEmail = session.Learner.ManagerEmailId; //_sManagerEmail = session.Learner.ManagerEmailId; //~ _sManagerEmail = _sManagerEmail.Replace("'", "\'"); //string sStudentEmail = session.Learner.EmailID; //~ sStudentEmail = sStudentEmail.Replace("'", "\'"); sStudentName = session.Learner.LastName + ", " + session.Learner.FirstName; string sCourseID = Request["contentmoduleid"]; //~string sCourseName = session.Assignment.ActivityName; string sCourseName = "HRS"; //~string sRVSettings = session.Learner.RegionViewName; string sRVSettings = "HRS"; string sIsScoreTracking = string.Empty; bool blnIsShortLanguageCode; ContentModuleTracking contModTracking = session.ContentModuleTracking; ContentModule entContent = session.ContentModule; //new ContentModule(); //blnIsShortLanguageCode = entContent.IsShortLanguageCode; iMasteryScore = 100;///****session.ContentModule.MasteryScore; ////sAVPath = session.Learner.AvPath; sIsScoreTracking = ""; sContentFolderUrl = System.Configuration.ConfigurationManager.AppSettings["sAppUrl"].ToString() + System.Configuration.ConfigurationManager.AppSettings["sContentFolderUrl"].ToString() + "/" + contentmoduleid; lblErr.Text = ""; if (!Page.IsPostBack) { lblWelcome.Text = sLearnerUserNameAlias; string strIMSCourseBasePath = sContentFolderUrl + "/"; string sAttempId = string.Empty; if (contModTracking.ID != null) { sAttempId = contModTracking.ID; LMSSession.AddSessionItem(ContentKeys.SESSION_ATTEMPT_ID, sAttempId); SessionManager.AddAttemptNumberToSession(sClientId, sessionId, contModTracking.ID); } int TotalNoOfPages = entContent.TotalLessons; totalscos = TotalNoOfPages.ToString(); LMSSession.AddSessionItem(ContentKeys.SESSION_TOTAL_NO_PAGES, TotalNoOfPages); lblContentModuleName.Text = sCourseName; lblMessage.Text = "To receive your certificate of completion you must view each screen in each section."; Response.Write("<script language='Javascript'>\n\tvar gLearnerId = \"" + sLearnerUserNameAlias + "\";\n"); Response.Write("\tvar gStudentId = \"" + sLearnerUserNameAlias + "\";\n"); Response.Write("\tvar sessionId = \"" + sessionId + "\";\n"); Response.Write("\tvar clientId = \"" + Request["clientId"] + "\";\n"); Response.Write("\tgLearnerName = \"" + sStudentName + "\";\n"); Response.Write("\tgContentPath=\"" + strIMSCourseBasePath + "\";\n"); Response.Write("\tvar gTrackScoreSettingFromLMS=\"" + sIsScoreTracking + "\";\n"); var sbLaunchParameter = new StringBuilder(); sbLaunchParameter.Append("LMSID=SAI"); if (!string.IsNullOrEmpty(sAVPath)) { sbLaunchParameter.Append("&AVPath=" + sAVPath); sbLaunchParameter.Append("&AudioPath=" + sAVPath); sbLaunchParameter.Append("&VideoPath=" + sAVPath); } if (!string.IsNullOrEmpty(sRVSettings)) { sbLaunchParameter.Append("&rip=" + sRVSettings); } if (!string.IsNullOrEmpty(sLearnerLanguageId)) { sLanguageCode = "en-US"; sbLaunchParameter.Append("&lang=" + sLanguageCode); } sLaunchParameter = sbLaunchParameter.ToString(); Response.Write("\tvar sLearnerLanguageId='" + sLanguageCode + "';\n"); Response.Write("\tvar gManifestId='" + sCourseID + "';\n</script>\n"); Response.Write("<script language='Javascript' src='ScormLibrary/js/ClientScripts.js'></script>\n"); Response.Write("<script language='Javascript' src='ScormLibrary/js/LMSRTEWrapperJS.js'></script>\n"); Response.Write("<script language='Javascript' src='ScormLibrary/js/Master.js'></script>\n"); Response.Write("<script language='Javascript' src='ScormLibrary/js/ScormValidations.js'></script>\n"); Response.Write("<script language='Javascript' src='ScormLibrary/js/RTEMaster.js'></script>\n"); Response.Write("<script language='Javascript' src='js/NewScormJS.js'></script>\n"); Response.Write("<script language='Javascript'>\n"); launchUrls = new Dictionary <string, string>(); lessonStatuses = new Dictionary <string, string>(); sections = entContent.Sections.SortedValues(); foreach (var section in sections) { foreach (var lesson in section.Lessons.SortedValues()) { var sco = (Sco)lesson; string sTempAVPath = sLaunchParameter != string.Empty ? sLaunchParameter : sco.DataFromLms; string siTempMasterScore; if (iMasteryScore > -1) { siTempMasterScore = Convert.ToString(iMasteryScore); } else { siTempMasterScore = sco.MasteryScore.HasValue ? sco.MasteryScore.ToString() : String.Empty; } var sUrl = sco.Resource.Href; if (sUrl.IndexOf(strIMSCourseBasePath) <= 0) { sUrl = sUrl.AppendUrlParameter("passingScore", siTempMasterScore) + "&" + sLaunchParameterQueryString; } launchUrls[lesson.Identifier] = sUrl; var arrOfNodeProp = String.Format( "['{0}','','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}']", sco.Identifier, sco.TargetWindow, sco.Prerequisites, sTempAVPath, siTempMasterScore, sco.MaxTimeAllowed, sco.TimeLimitAction, sco.Resource.Identifier, sco.Resource.ScormType, sco.Resource.Type, sco.Resource.Base, sUrl); Response.Write("\tarrManifestNodes[arrManifestNodes.length] = new ManifestNode(" + arrOfNodeProp + ");\n"); if (contModTracking.LessonTracking != null && contModTracking.LessonTracking.ContainsKey(lesson.Identifier)) { var scoTracking = contModTracking.LessonTracking[lesson.Identifier]; lessonStatuses[lesson.Identifier] = CommonManager.GetScoStatus(scoTracking.LessonStatus); WriteScoTracking(scoTracking); } else { lessonStatuses[lesson.Identifier] = CommonManager.GetScoStatus("not-started"); } } } Response.Write("</script>\n"); } }
//public ICoursePlayerAssignmentManager CoursePlayerAssignmentManager { get; set; } protected void Page_Load(object sender, EventArgs e) { // string aid = Request.Params["AID"]; //if (Request.Params["AID"] == null || Request.Params["client"] == null || // Request.Params["LID"] == null || Request.Params["Preview"] == null) if (Request.Params["AID"] == null || Request.Params["LID"] == null) { Response.Write("Course Preview not available. Please Contact Administrator."); Response.End(); } //Response.Write("<BR>AID : " + Request.Params["AID"]); //Response.Write("<BR>LID : " + Request.Params["LID"]); //Response.End(); //string activityId = CommonManager.DecodeAndDecrypt(Request.Params["AID"]); //string clientId = CommonManager.DecodeAndDecrypt(Request.Params["client"]); string activityId = Request.Params["AID"]; string learnerId = Request.Params["LID"]; string langId = Request.Params["Lang"]; if (string.IsNullOrEmpty(langId)) { langId = "en-US"; } LMSSession.AddSessionItem(CommonManager.SESSION_MYCULTURE, langId); bool isReview = CheckReview(); bool isForAdminPreview = false; bool isSsoLogin = CheckSso(); bool isSameWindow = CheckSameWindow(); string returnUrl = CheckReturnUrl(isForAdminPreview); int? gridPageSize = CheckGridPageSize(); var session = new ContentModuleSession { ContentModuleId = activityId, Expiration = DateTime.UtcNow.AddDays(2), IsReview = isReview, SystemUserGuid = learnerId, LaunchSite = isForAdminPreview ? LaunchSite.Admin : LaunchSite.Learner, SsoLogin = isSsoLogin, SameWindow = isSameWindow, ReturnUrl = returnUrl, GridPageSize = gridPageSize }; Course oCourse = new Course(); oCourse.ActivityId = activityId; oCourse.LearnerId = learnerId; var assignment = ContentModuleBLL.GetUserContentModuleTracking(oCourse); if (Convert.ToString(assignment.RetMessage) != "success") { Response.Write("Error Occured: " + Convert.ToString(assignment.RetMessage)); } // checks if activity already exists. if (assignment.ContentTrackId != null) { Learner oLearner = new Learner(); oLearner.ID = learnerId; LaunchActivity(assignment, session, oLearner); } }