]> _ Git - fluidbook-toolbox.git/commitdiff
wip #62050 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Sep 2023 17:38:10 +0000 (19:38 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 6 Sep 2023 17:38:10 +0000 (19:38 +0200)
app/Models/Quiz.php
app/SubForms/Quiz/Question.php
app/SubForms/TitleAndText.php [new file with mode: 0644]

index 0843de5a59896c0ecc4b76ce9341a8d0a700017b..644f8256ad1295d36a20d8e084976278dec456de 100644 (file)
@@ -138,14 +138,6 @@ class Quiz extends ToolboxModel
             'column' => true,
             'column_label' => '<i class="fa fa-language"></i>']);
 
-//        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']);
 
     }
index 5e529766ed53ade5f8f09d405a30299e22ff5e10..94e5ba5e57b50cbcb25b0196f949541fa063a6b3 100644 (file)
@@ -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 (file)
index 0000000..8d31298
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\SubForms;
+
+use Cubist\Backpack\Magic\Fields\Text;
+use Cubist\Backpack\Magic\Fields\Textarea;
+use Cubist\Backpack\Magic\SubForm;
+
+class TitleAndText extends SubForm
+{
+    public function init()
+    {
+        parent::init();
+        $this->addField('title', Text::class, '', ['placeholder' => __('Titre')]);
+        $this->addField('text', Textarea::class, '', ['placeholder' => __('Texte')]);
+    }
+}