From 3c9505840bcec0a5d15a48450343efd3de880a56 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 28 Feb 2020 20:03:17 +0100 Subject: [PATCH] wip #3438 @0.5 --- app/Models/Quiz.php | 11 ++++++++++- app/SubForms/Question.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/SubForms/Question.php diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 1dc196e..d79edf3 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -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 index 0000000..50877e3 --- /dev/null +++ b/app/SubForms/Question.php @@ -0,0 +1,33 @@ +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', + ]); + } +} -- 2.39.5