]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5041 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 10:56:23 +0000 (11:56 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 10:56:23 +0000 (11:56 +0100)
.idea/workspace.xml
app/Http/Controllers/Admin/Operations/ELearningPackage/ImportOperation.php
app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php
app/Jobs/ElearningPackageDownload.php
app/Models/ELearningPackage.php
app/Models/Quiz.php
resources/elearningpackage/js/app.js

index 74b2247b4dafcc0f075390777d62ac4f5d94fdb6..375ed6473bc1cf0fdd94ee2d7b905dbd7f56dd8b 100644 (file)
     <select />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @1">
+    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @0.25">
       <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$/app/Http/Controllers/Admin/Operations/ELearningPackage/ImportOperation.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/ELearningPackage/ImportOperation.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Jobs/ElearningPackageDownload.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Jobs/ElearningPackageDownload.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$/app/Models/Quiz.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/Quiz.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1644394645639" duration="13635000" />
       <workItem from="1644425348765" duration="2270000" />
       <workItem from="1644508187200" duration="10853000" />
-      <workItem from="1644582031422" duration="8408000" />
-    </task>
-    <task id="LOCAL-00195" summary="wip #4211 @1.5">
-      <created>1636127812133</created>
-      <option name="number" value="00195" />
-      <option name="presentableId" value="LOCAL-00195" />
-      <option name="project" value="LOCAL" />
-      <updated>1636127812134</updated>
+      <workItem from="1644582031422" duration="8556000" />
+      <workItem from="1644828785862" duration="4855000" />
     </task>
     <task id="LOCAL-00196" summary="wip #4211 @0.5">
       <created>1636131633680</created>
       <option name="project" value="LOCAL" />
       <updated>1644602356941</updated>
     </task>
-    <option name="localTasksCounter" value="244" />
+    <task id="LOCAL-00244" summary="wip #5041 @0.25">
+      <created>1644602746898</created>
+      <option name="number" value="00244" />
+      <option name="presentableId" value="LOCAL-00244" />
+      <option name="project" value="LOCAL" />
+      <updated>1644602746898</updated>
+    </task>
+    <option name="localTasksCounter" value="245" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="CHECK_NEW_TODO" value="false" />
     <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
-    <MESSAGE value="wait #4891 @2" />
     <MESSAGE value="wait #4928 @2" />
     <MESSAGE value="wait #4928 @0.25" />
     <MESSAGE value="wait #4891 @0.5" />
     <MESSAGE value="wip #5041 @1.5" />
     <MESSAGE value="wip #5041 @0.5" />
     <MESSAGE value="wip #5041 @1" />
-    <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @1" />
+    <MESSAGE value="wip #5041 @0.25" />
+    <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @0.25" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />
index 1f6629f159bee9f29b275083ec9a518023c18851..dcfdaf4af9831fc7e1156a46dd30d03a6144c905 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Admin\Operations\ELearningMedia;
+namespace App\Http\Controllers\Admin\Operations\ELearningPackage;
 
 use App\Models\Asset;
 use App\Models\ELearningMedia;
index 94c9447929c6326a7e64f0288700811e9e476eb6..d9919ca5f97c084d0c37a845a1ce2d5168959d57 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Admin\Operations\ELearningMedia;
+namespace App\Http\Controllers\Admin\Operations\ELearningPackage;
 
 use Cubist\Util\Files\Files;
 use Illuminate\Support\Facades\Route;
index 521dcdee41632adb213cb98fd020f74d53fbc396..d5de9a2d8d2df3e22ebeaa7daf06e90f9055c353 100644 (file)
@@ -15,7 +15,7 @@ class ElearningPackageDownload extends DownloadBase
     {
         try {
             $compilepath = $this->entry->getFinalPath();
-            $this->entry->compile($compilepath);
+            $this->entry->compile($compilepath,$this->user);
 
             $fname = $this->_fname();
             $dest = Files::mkdir(storage_path('app/public/elearningpackage/download/')) . $fname;
index 1d5183a034ba3a2f40d6f6a992dc7e79d42ebd2b..1e7ab8dae99c0c58dfa3e689157151a708127409 100644 (file)
@@ -2,9 +2,9 @@
 
 namespace App\Models;
 
-use App\Http\Controllers\Admin\Operations\ELearningMedia\ImportOperation;
-use App\Http\Controllers\Admin\Operations\ELearningMedia\PreviewOperation;
-use App\Http\Controllers\Admin\Operations\ELearningMedia\DownloadOperation;
+use App\Http\Controllers\Admin\Operations\ELearningPackage\ImportOperation;
+use App\Http\Controllers\Admin\Operations\ELearningPackage\PreviewOperation;
+use App\Http\Controllers\Admin\Operations\ELearningPackage\DownloadOperation;
 use App\Models\Base\ToolboxModel;
 use App\Services\WorkshopV2;
 use App\SubForms\ElearningPackageContent;
@@ -15,7 +15,6 @@ use Cubist\Scorm\Manifest;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Files\VirtualDirectory;
 use Cubist\Util\Zip;
-use Spatie\MediaLibrary\MediaCollections\Models\Media;
 
 class ELearningPackage extends ToolboxModel
 {
@@ -48,8 +47,11 @@ class ELearningPackage extends ToolboxModel
         return protected_path('elearningpackage/final/' . $this->id);
     }
 
-    public function compile($dest)
+    public function compile($dest, $user = null)
     {
+        if (null === $user) {
+            $user = backpack_user();
+        }
         $owner = User::withoutGlobalScopes()->findOrFail($this->owner);
         $organization = $owner->companyName;
 
@@ -58,7 +60,7 @@ class ELearningPackage extends ToolboxModel
         $modules = [];
 
         foreach ($this->contents as $id => $content) {
-            $m = $this->_compileModule($id, $content, $vdir);
+            $m = $this->_compileModule($id, $content, $vdir, $user);
             if ($m !== false) {
                 $modules[] = $m;
             }
@@ -80,9 +82,10 @@ class ELearningPackage extends ToolboxModel
      * @param $id int
      * @param $c array
      * @param $vdir VirtualDirectory
+     * @param $user User
      * @return array
      */
-    protected function _compileModule($id, $c, $vdir)
+    protected function _compileModule($id, $c, $vdir, $user)
     {
         $basePath = 'packages/' . $id . '/';
 
@@ -93,7 +96,7 @@ class ELearningPackage extends ToolboxModel
 
         switch ($res['type']) {
             case 'FB':
-                $moduleTitle = $this->_compileFluidbook($c['fb_id'], $vdir, $basePath);
+                $moduleTitle = $this->_compileFluidbook($c['fb_id'], $vdir, $basePath, $user);
                 break;
             case 'QZ':
                 $moduleTitle = $this->_compileQuiz($c['quiz_id'], $vdir, $basePath);
@@ -132,12 +135,12 @@ class ELearningPackage extends ToolboxModel
      * @param $basePath string
      * @return string
      */
-    protected function _compileFluidbook($id, $vdir, $basePath)
+    protected function _compileFluidbook($id, $vdir, $basePath, $user)
     {
         $tmp = Files::tmpdir();
         $vdir->addTemp($tmp);
 
-        $workshop = new WorkshopV2(backpack_user());
+        $workshop = new WorkshopV2($user);
         $workshop->installBook($id, $tmp, [], 'scorm');
 
         $vdir->copyDirectory($tmp, $basePath);
@@ -154,7 +157,7 @@ class ELearningPackage extends ToolboxModel
         if (null === $quiz) {
             return null;
         }
-        $quiz->compile($tmp);
+        $quiz->compile($tmp, true);
 
         $vdir->copyDirectory($tmp, $basePath);
         return $quiz->title;
index 492f773c94984135e202871825b1af8c6a4df885..6ef32da29c8a124175d1bef4595b000cdae06db7 100644 (file)
@@ -222,7 +222,7 @@ class Quiz extends ToolboxModel
     /**
      * @param $quiz self
      */
-    public function compile($dest)
+    public function compile($dest, $forceScorm = false)
     {
         // Clean existing dir and recreate it
         if (file_exists($dest)) {
@@ -258,7 +258,7 @@ class Quiz extends ToolboxModel
 
         file_put_contents($dest . '/data.js', 'var DATA=' . $json . ';');
 
-        if ($this->getAttribute('scorm')) {
+        if ($forceScorm || $this->getAttribute('scorm')) {
             $scorm_js = '<script src="js/libs/scorm/apiwrapper.js"></script>
 <script src="js/scorm.js"></script>';
             $title = htmlspecialchars($this->getAttribute('title'));
index 4562eb12e9fc117678e54891fe56d8bf36b0ec46..edb60c479202dceb5f5c46e09416b585ad7da40e 100644 (file)
@@ -253,10 +253,12 @@ function saveStatus() {
             globalScoreItems++;
         }
     }
+
     var score100 = globalScore / globalScoreItems;
     if (isNaN(score100)) {
         score100 = -1;
     }
+    console.log(score100, completed, score);
     if (score100 > 0) {
         setScormValue('cmi.score.raw', score100);
         setScormValue('cmi.score.scaled', score100 / 100);
@@ -354,7 +356,6 @@ function calcScore(s) {
     var max = doubleQuestionMark(s.cmi['cmi.core.score.max'], s.cmi['cmi.score.max'], 100);
     var min = doubleQuestionMark(s.cmi['cmi.core.score.min'], s.cmi['cmi.score.min'], 0);
 
-    console.log(raw, max, min);
     var scale = max - min;
     var norm = raw - min;
     if (isNaN(scale) || isNaN(norm)) {