} //Lesson_OnExit /// <summary> /// This method is called when a Quiz is Loaded. /// It looks up various pieces of data from the Salt tables /// before returning them to the Toolbook application /// </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 Quiz_OnLoad(string sessionID, NameValueCollection postData) { string strToolbookID; // the toolbook ID as per the toolbook application string strUserName; // the username int intUserID; // User ID of the current User int intModuleID; // Module ID that this quiz belongs to int intQuizID; // QuizID that the user is currently sitting int intPassMark; // The passmark for the quiz that the user is currently sitting int intUnitID; // The unit ID of the current user bool blnError; // Boolean flag indicating the presence of an error // Verify the necessary post parameters have been supplied strToolbookID = postData.Get("ToolbookID"); if (strToolbookID.Length == 0) { OutputToToolBook( cm_strReturnCodeCriticalError // paramater 1 - ReturnCode + cm_strDelimiter + "TBListener Error 1. Missing required parameter: ToolbookID" // paramater 2 - Error Message ); return; } // toolbook object used to return necessary information below.. BusinessServices.Toolbook objToolBook = new BusinessServices.Toolbook(); // Get UserName and ID strUserName = objToolBook.GetUser(sessionID); intUserID = objToolBook.GetUserIDBySessionID(sessionID); // Get Module ID and UserID to determine Access intModuleID = objToolBook.GetModuleIDBySessionID(sessionID); intUnitID = objToolBook.GetUnitIDByUserID(intUserID); // Get Quiz ID, Number of Quiz Questions and PassMark intQuizID = objToolBook.GetQuizIDBySessionID(sessionID); intPassMark = objToolBook.GetQuizPassMark(intUnitID, intModuleID); // Assume no errors to start with. blnError = false; // If no username if (strUserName.Length == 0) { OutputToToolBook( cm_strReturnCodeCriticalError + cm_strDelimiter + "TBListener Error 5. The User Name could not be found" + cm_strDelimiter + m_strRootURL + cm_strErrorLocation + "?errnum=5" ); blnError = true; } // If no Quiz ID if (intQuizID <= 0) { OutputToToolBook( cm_strReturnCodeCriticalError + cm_strDelimiter + "TBListener Error 6. The Quiz ID could not be found" + cm_strDelimiter + m_strRootURL + cm_strErrorLocation + "?errnum=6" ); blnError = true; } // If no module ID if (intModuleID <= 0) { OutputToToolBook( cm_strReturnCodeCriticalError + cm_strDelimiter + "TBListener Error 8. The Module ID Could not be found" + cm_strDelimiter + m_strRootURL + cm_strErrorLocation + "?errnum=8" ); blnError = true; } // If no Unit ID if (intUnitID <= 0) { OutputToToolBook( cm_strReturnCodeCriticalError + cm_strDelimiter + "TBListener Error 9. The Unit ID Could not be found" + cm_strDelimiter + m_strRootURL + cm_strErrorLocation + "?errnum=9" ); blnError = true; } // If no error has occurred if (!blnError) { // Start the quiz if (objToolBook.StartQuiz(sessionID)) { // Let Toolbook know that we have successfully started the quiz OutputToToolBook( cm_strReturnCodeOK // paramater 1 - ReturnCode + cm_strDelimiter + intPassMark // paramater 3 - PassMark + cm_strDelimiter + strUserName // paramater 4 - User Name + cm_strDelimiter + m_strRootURL + cm_strHomeLocation + "?SessionID=" + sessionID // paramater 5 - Exit Home URL + cm_strDelimiter + m_strRootURL + cm_strReportLocation + "?QuizSessionID=" + sessionID // paramater 6 - Exit Report URL + cm_strDelimiter + m_strRootURL + cm_strErrorLocation // paramater 7 - Error URL + cm_strDelimiter + "" // paramater 8 - Error Message ); return; } else { OutputToToolBook( cm_strReturnCodeCriticalError + 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." + cm_strDelimiter + m_strRootURL + cm_strHomeLocation + "?errnum=2" //cm_strErrorLocation ); return; } } } // Quiz_OnLoad
/// <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