]> _ Git - QuizFactory.git/commitdiff
wip #3438 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Feb 2020 19:03:17 +0000 (20:03 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Feb 2020 19:03:17 +0000 (20:03 +0100)
app/Models/Quiz.php
app/SubForms/Question.php [new file with mode: 0644]

index 1dc196eba6bb8756207cd9088c488f39585c31d4..d79edf3bd613797fd7fb92a7ae51221e5718dbb1 100644 (file)
@@ -39,7 +39,16 @@ class Quiz extends CubistMagicAbstractModel
             'label' => 'Quiz language',
             'type' => 'Locale',
             'column' => true,
-            'tab' => 'Texts and translations']);
+            'tab' => 'Settings']);
+
+        $this->addField([
+            'name' => 'questions',
+            'type' => 'BunchOfFieldsMultiple',
+            'bunch' => 'App\SubForms\Question',
+            'label' => 'Questions',
+            'add_label' => 'Add question',
+            'tab' => 'Questions / Answers',
+        ]);
 
         $colors = [
             'mainColor' => ['label' => 'Main color', 'hint' => 'Buttons and rollovers color'],
diff --git a/app/SubForms/Question.php b/app/SubForms/Question.php
new file mode 100644 (file)
index 0000000..50877e3
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+
+namespace App\SubForms;
+
+use Cubist\Backpack\app\Magic\SubForm;
+
+class Question extends SubForm
+{
+    public function init()
+    {
+        parent::init();
+
+        $this->addField(['name' => 'question',
+            'type' => 'Text',
+            'label' => 'Question']);
+
+        $this->addField(['name' => 'multiple',
+            'type' => 'Checkbox',
+            'label' => 'Multiple answers']);
+
+        $this->addField([
+            'name' => 'answers',
+            'type' => 'Table',
+            'entity_singular' => 'answer',
+            'columns' => [
+                'answer' => 'Answer label',
+                'correct' => 'Correct',
+            ],
+            'label' => 'Answers',
+        ]);
+    }
+}