/// <summary> /// Create context when the lesson starts /// </summary> private void CreateContext() { //1. Get Page Context LessonPageContext objContext = new LessonPageContext(); objContext.Path = Request.Url.AbsolutePath.Replace("/default.aspx", ""); objContext.StartTime = DateTime.Now; objContext.PageIndex = 0; objContext.Initialize(); PageContext.Current = objContext; //2. Get the bookmark, and change the current page index if bookmark exists if (!PageContext.Current.IsPreviewMode) { BusinessServices.Toolbook objToolbook = new BusinessServices.Toolbook(); string strBookmarkPageID = objToolbook.GetBookmark(objContext.SessionID); if (strBookmarkPageID != null) { try { objContext.PageIndex = objContext.FindPageIndex(strBookmarkPageID); } catch (ApplicationException) { // if a bookmark could not be found - ignore it. } } } }
/// <summary> /// Lesson_OnLoad /// </summary> /// <param name="sessionID">This is the session id that maps to the lesson that is currently loading</param> /// <param name="postData">This is the collection of http post data variables</param> private void Lesson_OnLoad(SqlString sessionID, NameValueCollection postData) { try { string strPagesVisited = ""; // List of pages already visited within this lesson string strBookmark = ""; // Bookmarked page, if any string strUsersName = ""; // User's full name DataTable dtbPagesVisitedResults; BusinessServices.Toolbook objToolBook = new BusinessServices.Toolbook(); // // TODO: any other validation including - dateExported, toolbookID // // Validate that this lesson has not been started before (based on the guid) // it should have no date completed if (!objToolBook.StartLesson(sessionID)) { //TODO: check this redirect : Response.Redirect(c_strHomeUrl); OutputToToolBook( cm_strReturnCodeCriticalError // paramater 1 - ReturnCode + cm_strDelimiter + ResourceManager.GetString("Error1") //"Please make sure you do not use your browser's backwards and forwards buttons. Navigate lessons and quizzes using the buttons in the bottom right hand corner." // paramater 2 - Error Message + cm_strDelimiter + m_strRootURL + cm_strHomeLocation + "?SessionID=" + (string)sessionID // paramater 3 - ExitURL ); return; } // Get pages visited dtbPagesVisitedResults = objToolBook.GetPagesVisited(sessionID); foreach (DataRow objPageVisited in dtbPagesVisitedResults.Rows) { if (strPagesVisited.Length > 0) { strPagesVisited += ","; } strPagesVisited += objPageVisited["ToolBookPageID"].ToString(); } // Get any Bookmark strBookmark = objToolBook.GetBookmark(sessionID); // Get user's full name strUsersName = objToolBook.GetUser(sessionID); OutputToToolBook( cm_strReturnCodeOK // paramater 1 - ReturnCode + cm_strDelimiter + strPagesVisited // paramater 2 - Pages Visited + cm_strDelimiter + strBookmark // paramater 3 - BookMark + cm_strDelimiter + strUsersName // paramater 4 - UserName + cm_strDelimiter + m_strRootURL + cm_strHomeLocation + "?SessionID=" + (string)sessionID // paramater 5 - ExitURL + cm_strDelimiter + m_strRootURL + cm_strErrorLocation + "?errnum=14" // paramater 6 - ErrorURL + cm_strDelimiter + "" // paramater 7 - Error Message ); // scussfully started lesson // - increase the session timeout Session.Timeout = 40; return; } catch (Exception ex) { //TODO: log this error OutputToToolBook( cm_strReturnCodeCriticalError // paramater 1 - ReturnCode + cm_strDelimiter + "TBListner Error 15. Unknown Error" + ex.Message // paramater 2 - Error Message + cm_strDelimiter + m_strRootURL + cm_strHomeLocation // paramater 3 - ExitURL ); return; } } //Lesson_OnLoad