public DownloadCourseFunction(CoursePageDownloader downloader, CourseParser parser, ILogger logger, Func <ILogger, CloudBlockBlobUpdater> cloudBlockBlobUpdater) { _downloader = downloader; _parser = parser; _logger = logger; _cloudBlockBlobUpdater = cloudBlockBlobUpdater(logger); }
public async Task ShouldParseCourseDetails(string domain, string filePath, string description, string[] googleMapIds) { using (var cancellationsPage = File.OpenRead(filePath)) { var parser = new CourseParser(); var course = await parser.Parse(cancellationsPage, domain); course.Should().BeEquivalentTo(new { Description = description, GoogleMapIds = googleMapIds }); } }
// Use this for initialization void Start() { var parser = new CourseParser(); var course = parser.ParseContent(CourseFile.text); //var course = new LevelAutoGenerator().Generate(200f); foreach(var piece in course.Track) { var piecePrefab = TrackPieces.FirstOrDefault(p => p.Name == piece.PieceName); if(piecePrefab != null) { var position = new Vector3(piece.PosX, piece.PosY, piece.PosZ); var rotation = Quaternion.Euler(new Vector3(0, piece.Rotation, 0)); Instantiate(piecePrefab.Prefab, position, rotation); } else { Debug.Log("Track piece " + piece.PieceName + " was not found. Ignoring...."); } } //Place player var player = GameObject.FindGameObjectWithTag("Player"); if(player != null) { player.transform.position = new Vector3(course.SpawnTrackpiece.PosX, course.SpawnTrackpiece.PosY + 5, course.SpawnTrackpiece.PosZ); player.transform.rotation = Quaternion.Euler(new Vector3(0, (float)course.Spawnpoint.Direction, 0)); } }
public ImportController() { _courseParser = new CourseParser(); _courseService = new CourseService(); }
public virtual string Export(int id, bool exportForPlayCourse = false) { var course = this.GetCourse(id); var path = this.GetCoursePath(id); if (course.Locked != null && course.Locked.Value) { return(path + ".zip"); } path = Path.Combine(path, Guid.NewGuid().ToString()); path = Path.Combine(path, course.Name); Directory.CreateDirectory(path); var nodes = this.GetNodes(id).ToList(); for (var i = 0; i < nodes.Count; i++) { if (nodes[i].IsFolder == false) { File.Copy(this.GetNodePath(nodes[i].Id) + ".html", Path.Combine(path, nodes[i].Id + ".html")); } else { var subNodes = GetNodes(id, nodes[i].Id); nodes.AddRange(subNodes); } } var coursePath = this.GetCoursePath(id); FileHelper.DirectoryCopy(Path.Combine(coursePath, "Node"), Path.Combine(path, "Node")); foreach (var file in this.templateFiles) { try { File.Copy(Path.Combine(coursePath, file), Path.Combine(path, file), true); } catch (FileNotFoundException) { continue; } } var helper = new ManifestManager(); var manifest = new Manifest(); var sw = new StreamWriter(Path.Combine(path, SCORM.ImsManifset)); var parentItem = new Item(); parentItem = this.AddSubItems(parentItem, null, id, helper, ref manifest); manifest.Organizations = ManifestManager.AddOrganization(manifest.Organizations, helper.CreateOrganization()); manifest.Organizations.Default = manifest.Organizations[0].Identifier; manifest.Organizations[0].Items = parentItem.Items; manifest.Organizations[0].Title = course.Name; if (course.Sequencing != null) { var xml = new XmlSerializer(typeof(Sequencing)); manifest.Organizations[0].Sequencing = (Sequencing)xml.DeserializeXElement(course.Sequencing); } var resource = new Resource { Identifier = ResourceIdForTemplateFiles, Files = this.templateFiles.Select(file => new ManifestModels.ResourceModels.File(file)).ToList(), ScormType = ScormType.Asset }; manifest.Resources = ManifestManager.AddResource(manifest.Resources, resource); ManifestManager.Serialize(manifest, sw); sw.Close(); Zipper.CreateZip(path + ".zip", path); if (exportForPlayCourse) { try { IudicoCourseInfo ci = CourseParser.Parse(course, this); this.AddCourseInfo(ci); } catch (Exception ex) { log.Error(string.Format("Exception message: {0}\nData: {1}\nHelp Link: {2}\nInner exception: {3}\nSource: {4}\nStack trace: {5}\nTarget site: {6}", ex.Message, ex.Data, ex.HelpLink, ex.InnerException, ex.Source, ex.StackTrace, ex.TargetSite)); } } return(path + ".zip"); }
public ParseCourseFunction(CourseParser parser, ILogger logger) { _parser = parser; _logger = logger; }