Exemplo n.º 1
0
 public static Chapter Load(string folderName, string urlName, EdxLoadOptions options)
 {
     return(Load <Chapter>(folderName, "chapter", urlName, options, c =>
     {
         c.Sequentials = c.SequentialReferences.Select(x => Sequential.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray();
         c.SequentialReferences = c.Sequentials.Select(v => v.GetReference()).ToArray();
     }));
 }
Exemplo n.º 2
0
 public static CourseWithChapters Load(string folderName, string urlName, EdxLoadOptions options)
 {
     return(Load <CourseWithChapters>(folderName, "course", urlName, options, c =>
     {
         c.Chapters = c.ChapterReferences.Select(x => Chapter.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray();
         c.ChapterReferences = c.Chapters.Select(v => v.GetReference()).ToArray();
     }));
 }
Exemplo n.º 3
0
 public static Sequential Load(string folderName, string urlName, EdxLoadOptions options)
 {
     return(Load <Sequential>(folderName, "sequential", urlName, options, seq =>
     {
         seq.Verticals = seq.VerticalReferences.Select(x => Vertical.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray();
         seq.VerticalReferences = seq.Verticals.Select(v => v.GetReference()).ToArray();
     }));
 }
Exemplo n.º 4
0
 public static Vertical Load(string folderName, string urlName, EdxLoadOptions options)
 {
     return(Load <Vertical>(folderName, "vertical", urlName, options, v =>
     {
         v.Components = v.ComponentReferences.Select(x => x.LoadComponent(folderName, x.UrlName, options)).ExceptNulls().ToArray();
         v.ComponentReferences = v.Components.Select(c => c.GetReference()).ToArray();
     }));
 }
Exemplo n.º 5
0
        public static EdxCourse Load(string folderName, EdxLoadOptions options = null)
        {
            options = options ?? new EdxLoadOptions();
            var course = new FileInfo($"{folderName}/course.xml").DeserializeXml <EdxCourse>();

            course.StaticFiles        = $"{folderName}/static".GetFiles();
            course.CourseWithChapters = CourseWithChapters.Load(folderName, course.UrlName, options);
            return(course);
        }
Exemplo n.º 6
0
 public override Component LoadComponent(string folderName, string urlName, EdxLoadOptions options)
 {
     return(SlideProblemComponent.Load(folderName, urlName, options));
 }
Exemplo n.º 7
0
 public virtual Component LoadComponent(string folderName, string urlName, EdxLoadOptions options)
 {
     return(null);
 }
Exemplo n.º 8
0
 public static TComponent Load <TComponent>(string folderName, string type, string urlName, EdxLoadOptions options, Action <TComponent> loadInner = null) where TComponent : EdxItem
 {
     try
     {
         var fileInfo = new FileInfo($"{folderName}/{type}/{urlName}.xml");
         if (!fileInfo.Exists)
         {
             if (options.FailOnNonExistingItem)
             {
                 throw new FileNotFoundException($"File {fileInfo.FullName} not found.");
             }
             else
             {
                 options.HandleNonExistentItemTypeName?.Invoke(type, urlName);
                 return(null);
             }
         }
         var component = fileInfo.DeserializeXml <TComponent>();
         component.UrlName = urlName;
         loadInner?.Invoke(component);
         return(component);
     }
     catch (Exception e)
     {
         throw new Exception($"{type} {urlName} load error", e);
     }
 }