private Dictionary <string, CourseSection> ReadSectionsFromManifest(string manifestPath, int masteryScore, ActivityContentType courseType) { var sections = new Dictionary <string, CourseSection>(); var manifestXml = new XmlDocument(); try { manifestXml.Load(manifestPath); manifestXml = new XMLLib().StripDocumentNamespace(manifestXml); } catch (Exception ex) { } XmlNodeList sectionNodeList = manifestXml.SelectNodes("/manifest/organizations/organization"); if (sectionNodeList == null) { return(sections); } var lessonReaderFactory = new LessonReaderFactory(courseType); int sectionNumber = 1; foreach (XmlNode sectionNode in sectionNodeList) { var titleNode = sectionNode.SelectSingleNode("title"); string title = titleNode == null ? String.Empty : titleNode.InnerText; string identifier = ((XmlElement)sectionNode).GetAttribute("identifier"); var lessons = new Dictionary <string, Lesson>(); XmlNodeList lessonNodeList = sectionNode.SelectNodes("//item[@identifierref | @resourceref]"); if (lessonNodeList != null) { int lessonNumber = 1; foreach (XmlNode lessonNode in lessonNodeList) { var lessonReader = lessonReaderFactory.GetLessonReader(lessonNode, masteryScore); var lesson = lessonReader.ReadLesson(); lesson.SortOrder = lessonNumber; lessons.Add(lesson.Identifier, lesson); lessonNumber++; } } sections.Add(identifier, new CourseSection { Lessons = lessons, Identifier = identifier, Title = title, SortOrder = sectionNumber }); sectionNumber++; } return(sections); }
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "GET") { ////if (LMSSession.IsInSession(Client.CLIENT_SESSION_ID)) //// hdnClientId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(Client.CLIENT_SESSION_ID))); if (LMSSession.IsInSession(ContentKeys.SESSION_ACTIVITYID)) { hdnContentModuleId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_ACTIVITYID))); courseId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_ACTIVITYID)); } if (LMSSession.IsInSession(ContentKeys.SESSION_LEARNER_ID)) { hdnUserId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID))); learnerId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID)); } hdnCStartDate.Value = Convert.ToString(DateTime.UtcNow); return; } var requestXml = LoadRequestXml(); XMLLib xLib = new XMLLib(); if (requestXml == null) { Response.Redirect("DisplayError.aspx?error=SessionTimeout"); } //sClientId = CommonManager.DecodeAndDecrypt(xLib.fGetValue(requestXml, "/Root/ClientId")); sessionId = xLib.fGetValue(requestXml, "/Root/SessionId"); courseId = EncryptionManager.Decrypt(Convert.ToString(hdnContentModuleId.Value)); if (LMSSession.IsInSession(ContentKeys.SESSION_LEARNER_ID)) { hdnUserId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID))); learnerId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID)); } if (requestXml != null) { XmlNode oRootNode = null; if (xLib.fCreateFirstContext(requestXml, "Root", ref oRootNode)) { string useCase = xLib.fGetValue(requestXml, "/Root/Case"); ProcessRequest(requestXml, useCase); } } }
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); }