public ILessonTrackingSerializer Create(ActivityContentType contentType, string courseId, string learnerId, string learnerName) { switch (contentType) { //case ActivityContentType.AICC: // return new AuTrackingSerializer // { // CourseId = courseId, // LearnerId = learnerId, // LearnerName = learnerName // }; case ActivityContentType.Scorm12: case ActivityContentType.Scorm2004: return(new ScoTrackingSerializer()); default: throw new ArgumentException("No serializer available for specified content type."); } }
public LessonReaderFactory(ActivityContentType courseType) { _courseType = courseType; }
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); }