From 3daea08f59d9f41e35b492d23adec8f863a0431e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 6 Sep 2023 19:38:10 +0200 Subject: [PATCH] wip #62050 @0.5 --- app/Models/Quiz.php | 26 ++++---------------------- app/SubForms/Quiz/Question.php | 7 ++++++- app/SubForms/TitleAndText.php | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 app/SubForms/TitleAndText.php diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 0843de5a5..644f8256a 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -138,14 +138,6 @@ class Quiz extends ToolboxModel 'column' => true, 'column_label' => '']); -// foreach (self::_getMessages() as $name => $label) { -// $this->addField(['name' => $name, -// 'label' => $label, -// 'hint' => __('Laisser vide pour utiliser le message par défaut'), -// 'type' => 'Text', -// ]); -// } - $this->addField('section_scorm', FormSection::class, __('SCORM')); $this->addField(['name' => 'scorm', @@ -246,10 +238,11 @@ class Quiz extends ToolboxModel $this->addField('section_advanced', FormSuperSection::class, __('Paramètres avancés')); $this->addField('section_advanced_', FormSection::class); + $this->addField(['name' => 'logattempts', 'label' => __('Activer l\'enregistrement des tentatives'), 'hint' => __('Les tentatives seront enregistrées sur le serveur de la Toolbox'), - 'type' => 'Checkbox', + 'type' => Checkbox::class, 'default' => false, 'when' => ['type' => 'quiz'], ]); @@ -258,8 +251,8 @@ class Quiz extends ToolboxModel $this->addField(['name' => $action, 'label' => $label, 'hint' => __('Code Javascript'), - 'type' => 'Textarea', - 'when' => ['type' => 'quiz'], + 'type' => Code::class, + 'when' => ['type' => 'quiz', 'language' => 'js'], ]); } @@ -273,17 +266,6 @@ class Quiz extends ToolboxModel ]); $this->addField('section_legacy', FormBigSection::class, __('Paramètres à supprimer')); - - $default = ['type' => 'Color']; - foreach (self::_getColors() as $name => $color) { - $f = array_merge($default, $color, ['name' => $name]); - $this->addField($f); - } - $default = ['type' => 'Images', 'maxFiles' => 1]; - foreach (self::_getImages() as $name => $label) { - $f = array_merge($default, ['name' => $name, 'label' => $label]); - $this->addField($f); - } $this->addField('css', Code::class, __('Code CSS supplémentaire'), ['language' => 'css']); } diff --git a/app/SubForms/Quiz/Question.php b/app/SubForms/Quiz/Question.php index 5e529766e..94e5ba5e5 100644 --- a/app/SubForms/Quiz/Question.php +++ b/app/SubForms/Quiz/Question.php @@ -3,6 +3,8 @@ namespace App\SubForms\Quiz; +use App\SubForms\TitleAndText; +use Cubist\Backpack\Magic\Fields\BunchOfFields; use Cubist\Backpack\Magic\Fields\Checkbox; use Cubist\Backpack\Magic\Fields\FormSeparator; use Cubist\Backpack\Magic\Fields\Integer; @@ -41,6 +43,9 @@ class Question extends SubForm ] ]); + $this->addField('area_1', BunchOfFields::class, __('Zone 1'), ['when' => ['type' => 'draganddrop'], 'bunch' => TitleAndText::class]); + $this->addField('area_2', BunchOfFields::class, __('Zone 2'), ['when' => ['type' => 'draganddrop'], 'bunch' => TitleAndText::class]); + $this->addField(['name' => 'placeholder', 'type' => 'Text', 'label' => __('Placeholder'), @@ -77,7 +82,7 @@ class Question extends SubForm 'bunch' => Answer::class, 'add_label' => __('Nouvelle réponse'), 'label' => __('Réponses'), - 'when' => ['type' => 'multiple'] + 'when' => ['type' => ['multiple', 'draganddrop']] ]); $this->addField('', FormSeparator::class); $this->addField('countdown_enable', Checkbox::class, __('Définir un temps de réponse limite')); diff --git a/app/SubForms/TitleAndText.php b/app/SubForms/TitleAndText.php new file mode 100644 index 000000000..8d3129830 --- /dev/null +++ b/app/SubForms/TitleAndText.php @@ -0,0 +1,17 @@ +addField('title', Text::class, '', ['placeholder' => __('Titre')]); + $this->addField('text', Textarea::class, '', ['placeholder' => __('Texte')]); + } +} -- 2.39.5