]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6594 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jan 2024 11:54:12 +0000 (12:54 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jan 2024 11:54:12 +0000 (12:54 +0100)
app/Elearning/QuizCompiler.php
app/Models/Quiz.php

index 0f52ad89a835b7a43a357c64be7db58a3cb8a632..bc0e1f15c9c15fc2a1cf5e22e497b25a76800a51 100644 (file)
@@ -6,13 +6,9 @@ use App\Elearning\QuizCompiler\Animations;
 use App\Elearning\QuizCompiler\Credits;
 use App\Elearning\QuizCompiler\L10N;
 use App\Fields\FluidbookFont;
-use App\Fields\HorizontalAlign;
-use App\Fields\ThemeBackgroundSize;
-use App\Fields\VerticalAlign;
 use App\Jobs\Base;
 use App\Models\Quiz;
 use App\Models\QuizTheme;
-use App\Models\Signature;
 use App\Models\Traits\QuizBranches;
 use Cubist\Scorm\Manifest;
 use Cubist\Scorm\Version;
@@ -22,6 +18,7 @@ use Cubist\Util\Files\Files;
 use Cubist\Util\Files\VirtualDirectory;
 use Cubist\Util\Graphics\Color;
 use Cubist\Util\Text;
+use GrahamCampbell\Markdown\Facades\Markdown;
 use RyanChandler\Blade\Blade;
 
 class QuizCompiler extends Base
@@ -92,13 +89,25 @@ class QuizCompiler extends Base
 
         $l10n = $this->data->l10n;
         $blade = new Blade($this->_resourcesPath() . '/views', $this->_resourcesPath() . '/cache/' . md5(rand(100000, 10000000)) . '/');
-        $html = $blade->make('index', ['data' => $this->data, 'quiz' => $this->quiz, 'theme' => $this->theme, '__' => function ($str, $replace = [], $locale = null) use ($l10n) {
-            $str = $l10n[$str] ?? '~' . $str;
-            if (!$replace) {
-                return $str;
-            }
-            return Text::l10nReplacements($str, $replace);
-        }])->render();
+
+        $bladeData = [
+            'data' => $this->data,
+            'quiz' => $this->quiz,
+            'theme' => $this->theme,
+            '__' => function ($str, $replace = [], $locale = null) use ($l10n) {
+                $str = $l10n[$str] ?? '~' . $str;
+                if (!$replace) {
+                    return $str;
+                }
+                return Text::l10nReplacements($str, $replace);
+            },
+            'markdownToHTML' => function ($markdown) {
+                return Markdown::convert($markdown)->getContent();
+            },
+        ];
+
+
+        $html = $blade->make('index', $bladeData)->render();
 
         $vdir->file_put_contents('index.html', $html);
 
index 6ea20c2cbce551e3215d46fddb56cf55c8ae35a0..af7bebbb2f06fd7c4706b773ae7e793824442f7c 100644 (file)
@@ -23,9 +23,9 @@ use Cubist\Backpack\Magic\Fields\FormSection;
 use Cubist\Backpack\Magic\Fields\FormSeparator;
 use Cubist\Backpack\Magic\Fields\FormSuperSection;
 use Cubist\Backpack\Magic\Fields\Hidden;
+use Cubist\Backpack\Magic\Fields\MarkdownBasic;
 use Cubist\Backpack\Magic\Fields\SelectFromArray;
 use Cubist\Backpack\Magic\Fields\Text;
-use Cubist\Backpack\Magic\Fields\Textarea;
 use Spatie\Image\Manipulations;
 use Spatie\MediaLibrary\MediaCollections\Models\Media;
 
@@ -190,12 +190,12 @@ class Quiz extends ToolboxModel
         $this->addField('section_intro', FormSection::class, __('Introduction'));
         $this->addField('intro_enable', Checkbox::class, __('Activer l\'écran d\'introduction'), ['default' => 1]);
         $this->addField('intro_title', Text::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1']]]);
-        $this->addField('intro_text', Textarea::class, __('Texte d\'introduction'), ['when' => ['intro_enable' => ['1']]]);
+        $this->addField('intro_text', MarkdownBasic::class, __('Texte d\'introduction'), ['when' => ['intro_enable' => ['1']]]);
         $this->addField('intro_button', Text::class, __('Texte du bouton d\'introduction'), ['when' => ['intro_enable' => ['1']]]);
         $this->addField('', FormSeparator::class);
         $this->addField('intro_custom_mobile', Checkbox::class, __('Personnaliser les textes sur Mobile'), ['when' => ['intro_enable' => ['1']]]);
         $this->addField('intro_title_mobile', Text::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1'], 'intro_custom_mobile' => ['1']]]);
-        $this->addField('intro_text_mobile', Textarea::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1'], 'intro_custom_mobile' => ['1']]]);
+        $this->addField('intro_text_mobile', MarkdownBasic::class, __('Titre d\'introduction'), ['when' => ['intro_enable' => ['1'], 'intro_custom_mobile' => ['1']]]);
         $this->addField('intro_button_mobile', Text::class, __('Texte du bouton d\'introduction'), ['when' => ['intro_enable' => ['1'], 'intro_custom_mobile' => ['1']]]);
 
         $this->addField('section_score', FormSection::class, __('Fin du quiz'));