]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6388
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Oct 2023 18:26:03 +0000 (20:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Oct 2023 18:26:03 +0000 (20:26 +0200)
app/Elearning/QuizCompiler.php
app/Elearning/QuizCompiler/Credits.php [new file with mode: 0644]
app/Models/Quiz.php

index 72c6579761e78388519a48b46d9e4ed82914fd45..a89634e7d194b525a28fcc747014fee5399df217 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Elearning;
 
 use App\Elearning\QuizCompiler\Animations;
+use App\Elearning\QuizCompiler\Credits;
 use App\Elearning\QuizCompiler\L10N;
 use App\Fields\FluidbookFont;
 use App\Fields\HorizontalAlign;
@@ -11,6 +12,7 @@ use App\Fields\VerticalAlign;
 use App\Jobs\Base;
 use App\Models\Quiz;
 use App\Models\QuizTheme;
+use App\Models\Signature;
 use Cubist\Scorm\Manifest;
 use Cubist\Scorm\Version;
 use Cubist\Util\CommandLine\Npx;
@@ -26,6 +28,7 @@ class QuizCompiler extends Base
 
     use Animations;
     use L10N;
+    use Credits;
 
     /**
      * @var Quiz
@@ -74,6 +77,7 @@ class QuizCompiler extends Base
         $this->writeStyles();
         $this->writeAnimations();
         $this->writeL10n();
+        $this->writeCredits();
         $this->writeData();
         // Run the compiler
         $this->runWebpack();
@@ -319,4 +323,6 @@ class QuizCompiler extends Base
             }
         }
     }
+
+
 }
diff --git a/app/Elearning/QuizCompiler/Credits.php b/app/Elearning/QuizCompiler/Credits.php
new file mode 100644 (file)
index 0000000..73842d9
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Elearning\QuizCompiler;
+
+use App\Models\Signature;
+
+trait Credits
+{
+    protected $signature;
+
+    protected function writeCredits()
+    {
+        if (null === $this->signature) {
+            $this->signature = Signature::withoutGlobalScopes()->find($this->quiz->signature);
+            if (null === $this->signature) {
+                $this->signature = Signature::withoutGlobalScopes()->find(1);
+            }
+            $credits = $this->signature->credits;
+        } else {
+            $credits = '';
+        }
+        $this->data->set('credits', $credits);
+    }
+}
index 6e253818b7876025577801a47e8511b653702390..c3136b6537b2161d336469c727e5678c506323e4 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Models;
 
 use App\Elearning\QuizCompiler;
 use App\Fields\ElearningLocale;
+use App\Fields\FluidbookSignature;
 use App\Fields\QuizDevelopmentVersion;
 use App\Fields\SCORMVersion;
 use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
@@ -139,6 +140,11 @@ class Quiz extends ToolboxModel
             'database_default' => 'quiz',
         ]);
 
+        $this->addField('signature', FluidbookSignature::class, __('Signature'), [
+            'default' => '1',
+            'databaseDefault' => '1',
+        ]);
+
         $this->addField('section_translation', FormSection::class, __('Langue'));
         $this->addField(['name' => 'translation',
             'label' => __('Langue'),