From: Vincent Vanwaelscappel Date: Wed, 3 Jan 2024 11:54:12 +0000 (+0100) Subject: wait #6594 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ed92da1d7ada34da625b63e24251b2ae622fade1;p=fluidbook-toolbox.git wait #6594 @1 --- diff --git a/app/Elearning/QuizCompiler.php b/app/Elearning/QuizCompiler.php index 0f52ad89a..bc0e1f15c 100644 --- a/app/Elearning/QuizCompiler.php +++ b/app/Elearning/QuizCompiler.php @@ -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); diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 6ea20c2cb..af7bebbb2 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -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'));