]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5041 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 11 Feb 2022 12:43:28 +0000 (13:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 11 Feb 2022 12:43:28 +0000 (13:43 +0100)
.idea/workspace.xml
app/Models/ELearningMedia.php
app/Models/ELearningPackage.php
resources/elearningpackage/js/app.js
resources/views/elearningmedia/index.blade.php

index 29171cce11c3c229a83c3c8d6b309bbfa60e78dc..b2c6648217c6bf0260a7d2f127d9080840402b4e 100644 (file)
     <select />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @1.5">
+    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/resources/elearningmedia/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningmedia/js/app.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/resources/elearningmedia/js/spectrum.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningmedia/js/spectrum.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Models/ELearningMedia.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/ELearningMedia.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Models/ELearningPackage.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/ELearningPackage.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/resources/views/elearningmedia/index.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/elearningmedia/index.blade.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1644343001625" duration="4220000" />
       <workItem from="1644394645639" duration="13635000" />
       <workItem from="1644425348765" duration="2270000" />
-      <workItem from="1644508187200" duration="9909000" />
-    </task>
-    <task id="LOCAL-00190" summary="wip #4857 @1">
-      <created>1635949750599</created>
-      <option name="number" value="00190" />
-      <option name="presentableId" value="LOCAL-00190" />
-      <option name="project" value="LOCAL" />
-      <updated>1635949750599</updated>
+      <workItem from="1644508187200" duration="10853000" />
+      <workItem from="1644582031422" duration="1260000" />
     </task>
     <task id="LOCAL-00191" summary="wip #3753 @2">
       <created>1636044131486</created>
       <option name="project" value="LOCAL" />
       <updated>1644578113366</updated>
     </task>
-    <option name="localTasksCounter" value="239" />
+    <task id="LOCAL-00239" summary="wip #5041">
+      <created>1644578457525</created>
+      <option name="number" value="00239" />
+      <option name="presentableId" value="LOCAL-00239" />
+      <option name="project" value="LOCAL" />
+      <updated>1644578457525</updated>
+    </task>
+    <option name="localTasksCounter" value="240" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <MESSAGE value="wip #5045 @0.75" />
     <MESSAGE value="wip #5045 @1.1" />
     <MESSAGE value="wait #5045 @0.5" />
-    <MESSAGE value="wip #5041" />
     <MESSAGE value="wip #5041 @1" />
     <MESSAGE value="wip #5041 @3" />
     <MESSAGE value="wip #5041 @1.5" />
-    <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @1.5" />
+    <MESSAGE value="wip #5041" />
+    <option name="LAST_COMMIT_MESSAGE" value="wip #5041" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />
index ba322a7968841eddac2a5ebcf786873189d6b4c1..f0bc15b9620ccb9b7d7b27046a64005b74077d69 100644 (file)
@@ -62,17 +62,37 @@ class ELearningMedia extends ToolboxModel
         $owner = User::withoutGlobalScopes()->findOrFail($this->owner);
         $organization = $owner->companyName;
 
+
+        /** @var Media $file */
+        $file = $this->getMediaInField('file')->first()->getPath();
+        self::compileFromFile($file, $dest, $this->title, $organization, 'MEDIA_' . $this->id, 75);
+    }
+
+    /**
+     * @param $file string
+     * @param $dest string
+     * @param $title string
+     * @param $organization string
+     * @param $reference string
+     * @param $complete_pct int
+     * @return string
+     * @throws \Exception
+     */
+    public static function compileFromFile($file, $dest, $title, $organization, $reference, $complete_pct = 75)
+    {
+        $spl = new \SplFileInfo($file);
+        $ext = mb_strtolower($spl->getExtension());
+        if (!$title) {
+            $title = $spl->getBasename('.' . $spl->getExtension());
+        }
         $vdir = new VirtualDirectory($dest);
-        $vdir->file_put_contents('imsmanifest.xml', new Manifest($this->title, Manifest::SCORM_2004, $organization, 'MEDIA_' . $this->id));
+        $vdir->file_put_contents('imsmanifest.xml', new Manifest($title, Manifest::SCORM_2004, $organization, $reference));
         $vdir->copyDirectory(resource_path('elearningmedia/dist/css'), 'css');
         $vdir->copyDirectory(resource_path('elearningmedia/dist/js'), 'js');
-        /** @var Media $file */
-        $file = $this->getMediaInField('file')->first();
-        $spl = new \SplFileInfo($file->getPath());
-        $ext = mb_strtolower($spl->getExtension());
-        $vdir->copy($file->getPath(), 'media.' . $ext);
-        $vdir->file_put_contents('index.html', view('elearningmedia.index', ['media' => $this->getPageData(), 'type' => $ext === 'mp3' ? 'audio' : 'video']));
+        $vdir->copy($file, 'media.' . $ext);
+        $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $ext === 'mp3' ? 'audio' : 'video']));
         $vdir->sync(true);
+        return $title;
     }
 
     public function getIdTitleAttribute()
index 2c9084046f5cffe54fa8824a6e35e3fbb5c092a8..6dd88910332d07a779cbfffe7a18309d0f744893 100644 (file)
@@ -60,7 +60,7 @@ class ELearningPackage extends ToolboxModel
             $modules[] = $this->_compileModule($id, $content, $vdir);
         }
 
-        $data = ['title' => $this->title, 'description' => $this->description, 'module' => $modules];
+        $data = ['title' => $this->title, 'description' => $this->description, 'modules' => $modules];
 
         $vdir->file_put_contents('data.js', 'const DATA=' . json_encode($data) . ';');
         $vdir->file_put_contents('imsmanifest.xml', new Manifest($this->title, Manifest::SCORM_2004, $organization, 'PACKAGE_' . $this->id));
@@ -148,9 +148,31 @@ class ELearningPackage extends ToolboxModel
         return $quiz->title;
     }
 
-    protected function _compileMedia($c, $vdir, $basePath)
+    protected function _compileMedia($media_id, $media_file, $vdir, $basePath)
     {
+        if ($media_id) {
+            return $this->_compileMediaFromElearningMedia($media_id, $vdir, $basePath);
+        }
+        $tmp = Files::tmpdir();
+        $vdir->addTemp($tmp);
+
+        $owner = User::withoutGlobalScopes()->findOrFail($this->owner);
+        $organization = $owner->companyName;
+
+        $file = $this->getMediaByCollection($media_file)->first()->getPath();
+        return ELearningMedia::compileFromFile($file, $tmp, '', $organization, 'MEDIA_' . $media_file);
+    }
 
+    protected function _compileMediaFromElearningMedia($id, $vdir, $basePath)
+    {
+        $tmp = Files::tmpdir();
+        $vdir->addTemp($tmp);
+
+        $media = ELearningMedia::find($id);
+        $media->compile($tmp);
+
+        $vdir->copyDirectory($tmp, $basePath);
+        return $media->title;
     }
 
     protected function _compilePDF($collection, $vdir, $basePath)
index 9056e088bfe875eee7137785321ecf337cc853af..9249eec442e7678ff1d6479c9abeaa5bfd37689c 100644 (file)
@@ -287,7 +287,16 @@ function setContents() {
     }
     var vcheck = getSpriteIcon('check-ok');
     var xcheck = getSpriteIcon('check-nok');
-    var types = {IN: 'Infographic PDF', AN: 'Animation', VI: 'Video', FB: 'Fluidbook', PC: 'Podcast HTML', QZ: 'Quiz'};
+    var types = {
+        IN: 'Infographic PDF',
+        AN: 'Animation',
+        FC: 'Flipcards',
+        Ti5: 'Video',
+        VI: 'Video',
+        FB: 'Fluidbook',
+        PD: 'Podcast',
+        QZ: 'Quiz'
+    };
     $('header h1').text(DATA.title);
     $('header p').text(DATA.description);
     $('title').text(DATA.title);
index 19da5565187cc2ed68fa6666e99d225a6d3455b9..ea16d694149d1f6af6290e88fc898e4daa4dc708 100644 (file)
@@ -3,7 +3,7 @@
 <head>
     <meta charset="UTF-8">
     <link href="css/app.css" rel="stylesheet">
-    <title>{{$media->get('title')}}</title>
+    <title>{{$title}}</title>
 </head>
 <body>
 @if($type==='audio')
@@ -17,7 +17,7 @@
         <source src="media.mp4" type="video/mp4"/>
     </video>
 @endif
-<script>var progressComplete = {{$media->get('complete_pct')}};</script>
+<script>var progressComplete = {{$complete_pct}};</script>
 <script src="js/app.js"></script>
 </body>
 </html>