public Course AddCourse(RegisterCourseViewModel model, int customerId) { Course course = new Course() { CustomerId = customerId, Description = model.Description, Name = model.Name, TimeStamp = DateTime.Now, }; _courseRepository.Add(course); Scene scene = new Scene() { CourseId = course.Id }; _sceneService.AddScene(scene); VRBackground background = new VRBackground() { SceneId = scene.Id }; _backgroundService.AddImage(background); return(course); }
public void SaveBackground(IFormFile file, int sceneId) { Scene scene = _sceneService.GetScene(sceneId); if (scene != null) { if (file.ContentType.StartsWith("image/")) { byte[] p1 = null; using (var fs1 = file.OpenReadStream()) using (var ms1 = new MemoryStream()) { fs1.CopyTo(ms1); p1 = ms1.ToArray(); } VRBackground background = new VRBackground() { Img = p1, Colour = "#FFFFFF", SceneId = sceneId, }; if (_VRBackgroundRepository.getBackgroundWithSceneId(sceneId) != null) { _VRBackgroundRepository.UpdateBackground(background); } else { _VRBackgroundRepository.AddBackground(background); } } } }
public void AddScene(Scene scene) { _sceneRepository.Add(scene); VRBackground image = new VRBackground() { SceneId = scene.Id, }; _VRBackgroundService.Add(image); }
public async Task <IActionResult> Export(int courseId) { // Get the course to be exported Course course = _courseService.GetCourse(courseId); // Create export directory under the courses ID CreateExportDirectory(course.Id); // Get all scenes under the course IEnumerable <Scene> scenes = _sceneService.GetScenesWithCourseId(courseId); // Set the scene index to 0 int sceneIndex = 0; // cycle through each scene foreach (Scene item in scenes) { // Get all the vr Objects in the scene IEnumerable <VRObject> vRObjects = _VRObjectService.GetVROBjectsWithSceneId(item.Id); // for each vr object, if it's video or audio, find the file in the MEDIA folder and move it to the scorm content folder foreach (VRObject v in vRObjects) { if (v.ObjectType == "VideoObject" || v.ObjectType == "AudioObject") { MoveMediaFileToScormContentFolder(v.ObjectType, v.Value, courseId); } } // Getting all the hotspot, question and responses in the scene IEnumerable <VRHotspot> vRHotspots = _VRObjectService.GetVRHotspotsWithSceneId(item.Id); IEnumerable <VRQuestionCard> vRQuestionCards = _VRObjectService.GetVRQuestionsWithSceneId(item.Id); IEnumerable <VRQuestionResponse> tempResponses = new List <VRQuestionResponse>(); List <VRQuestionResponse> responses = new List <VRQuestionResponse>(); if (vRQuestionCards != null && vRQuestionCards.Count() > 0) { foreach (VRQuestionCard q in vRQuestionCards) { // stores the individual question's responses in temp responses // This is reset each iteration of the foreach loop tempResponses = _VRObjectService.GetVRQuestionresponsesWithQuestionId(q.Id); foreach (VRQuestionResponse r in tempResponses) { // iterate through the tempResponses to add the response to the responses to be exported responses.Add(r); } } } // Get the current scenes background image VRBackground Image = _VRBackgroundService.getBackgroundImageObjectWithSceneId(item.Id); // Export Model to be passed to export.cshtml ExportModel eModel = new ExportModel() { backgroundImage = Image, VRObjects = vRObjects, VRHotSpots = vRHotspots, VRQuestionCards = vRQuestionCards, VRQuestionResponses = responses }; // Returns a string of the Export.cshtml after it has been populated with the above data string exportView = await this.RenderViewToStringAsync("/Views/Export/Export.cshtml", eModel); // Writes the above data to a html file for each scene WriteToFile(exportView, item.CourseId, sceneIndex); sceneIndex++; } // once the loop is complete, zip it as per the xAPI standard wrapper docs ZipScorm(course.Id); // Relocate from the ZIPS to be downloaded by the user FileStreamResult fileStreamResult = null; try { string path = "C:/OPT/ZIPS/" + courseId + ".zip"; FileStream fileStreamInput = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Delete); fileStreamResult = new FileStreamResult(fileStreamInput, "APPLICATION/octet-stream"); fileStreamResult.FileDownloadName = "yourScorm.zip"; } catch (Exception e) { Console.WriteLine(e); } finally { // Ensure the zip is always deleted so the course can be downlaoded multiple times DeleteExportedZip(course.Id); } return(fileStreamResult); }
public void AddImage(VRBackground img) { _VRBackgroundRepository.Add(img); }