public static short GetTotalPages(string clientId, string courseId) { string cacheKey = "PageCount-" + clientId + "-" + courseId; short TotalNoOfPages = 0; if (HttpContext.Current.Cache[cacheKey] == null) { string rootSharedPath = "root content path"; ContentModule entContent = new ContentModule(); ContentModuleManager entContentModuleManager = new ContentModuleManager(); entContent.ID = courseId; entContent.ClientId = clientId; entContent = entContentModuleManager.Execute(entContent, ContentModule.Method.GetByIDCoursePlayer); string sContentFolderPath = rootSharedPath + entContent.ContentModuleURL.Replace("/", @"\\"); string IMSManifestPath; if (String.IsNullOrEmpty(entContent.ImanifestUrl)) { IMSManifestPath = sContentFolderPath + "\\\\imsmanifest.xml"; } else { IMSManifestPath = rootSharedPath + entContent.ImanifestUrl.Replace("/", @"\"); } XmlNamespaceManager nsmanager; XMLLib xLib = new XMLLib(); XmlDocument oIMSXMLObj = null; XmlNodeList ScoNodeList = null; if (!xLib.fOpenFreeXMLDoc(ref oIMSXMLObj, IMSManifestPath)) { return(0); } nsmanager = new XmlNamespaceManager(oIMSXMLObj.NameTable); nsmanager.AddNamespace("adlcp", "http://www.adlnet.org/xsd/adlcp_rootv1p2"); oIMSXMLObj = xLib.StripDocumentNamespace(oIMSXMLObj); xLib.NSManager = nsmanager; XmlNode lRsrcNode = null; if (oIMSXMLObj != null) { xLib.fCreateContext(oIMSXMLObj, "/manifest/organizations/organization//item", ref ScoNodeList); foreach (XmlNode lItemNode in ScoNodeList) { string lIdentifierref = xLib.fDirectGetValue(lItemNode, "@identifierref"); if (lIdentifierref != "") { if (xLib.fCreateFirstContext(oIMSXMLObj, "/manifest/resources/resource[@identifier='" + lIdentifierref + "']", ref lRsrcNode)) { TotalNoOfPages++; } } } } HttpContext.Current.Cache.Insert(cacheKey, TotalNoOfPages, new CacheDependency(IMSManifestPath)); } else { TotalNoOfPages = Convert.ToInt16(HttpContext.Current.Cache[cacheKey]); } return(TotalNoOfPages); }
private void ProcessRequest(XmlDocument RequestXMLObj, string useCase) { switch (useCase) { case "SaveCurrentSco": try { string strContentModuleId = string.Empty; string strLearnerId = string.Empty; ////string strClientId = string.Empty; if (LMSSession.IsInSession(ContentKeys.SESSION_ACTIVITYID)) { strContentModuleId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_ACTIVITYID)); } if (LMSSession.IsInSession(ContentKeys.SESSION_LEARNER_ID)) { strLearnerId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID)); } ////if (LMSSession.IsInSession(Client.CLIENT_SESSION_ID)) //// strClientId = Convert.ToString(LMSSession.GetValue(Client.CLIENT_SESSION_ID)); ////if (string.IsNullOrEmpty(strClientId) && !string.IsNullOrEmpty(hdnClientId.Value)) ////{ //// strClientId = EncryptionManager.Decrypt(hdnClientId.Value); ////} if (!string.IsNullOrEmpty(hdnContentModuleId.Value)) { strContentModuleId = EncryptionManager.Decrypt(hdnContentModuleId.Value); } if (!String.IsNullOrEmpty(strContentModuleId)) { bool flag = false; if (hdnContentModuleIdIsA.Value == String.Empty) { ContentModuleManager _CMManager = new ContentModuleManager(); ContentModule entContentModule = new ContentModule(); entContentModule.ID = strContentModuleId; ////entContentModule.ClientId = strClientId; entContentModule = _CMManager.Execute(entContentModule, ContentModule.Method.GetByIDCoursePlayer); flag = entContentModule.IsAssessment; hdnContentModuleIdIsA.Value = entContentModule.IsAssessment.ToString(); } else { flag = Convert.ToBoolean(hdnContentModuleIdIsA.Value); } if (flag) { SaveSuspendData(RequestXMLObj); } } else { RedirectToMainPage(); } } catch (Exception ex) { } SaveCurrentSco(RequestXMLObj); ////string xmlFromPost = Request["TARecords"]; break; } }
/// <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"); } }