From 77449f7fb516bd42bb3024be84fc6802c73dadc5 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 4 Mar 2020 16:34:03 +0100 Subject: [PATCH] done #3438 @1 --- app/Models/Quiz.php | 70 ++++++++++++++----- app/Models/QuizTranslation.php | 11 +++ .../cubist/fluidbooktoolbox/css/style.less | 4 ++ 3 files changed, 67 insertions(+), 18 deletions(-) diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 8d44a61a0..ab39b96c2 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -46,7 +46,36 @@ class Quiz extends CubistMagicAbstractModel 'label' => 'Quiz title', 'type' => 'Text', 'column' => true, - 'tab' => 'Settings']); + 'tab' => 'Contents']); + + $this->addField(['name' => 'translation', + 'label' => 'Quiz language', + 'type' => 'SelectFromModel', + 'optionsmodel' => QuizTranslation::class, + 'attribute' => 'locale', + 'column' => true, + 'tab' => 'Contents']); + + $messages = ['defaultMessage' => 'Message displayed at the end of the quiz', + 'passedMessage' => 'Message displayed when passing the quiz', + 'failedMessage' => 'Message displayed when failing the quiz']; + + foreach ($messages as $name => $label) { + $this->addField(['name' => $name, + 'label' => $label, + 'hint' => 'Let this field empty to use the default message', + 'type' => 'Text', + 'tab' => 'Contents']); + } + + $this->addField([ + 'name' => 'questions', + 'type' => 'BunchOfFieldsMultiple', + 'bunch' => 'App\SubForms\Question', + 'label' => '', + 'add_label' => 'Add question', + 'tab' => 'Questions / Answers', + ]); $this->addField(['name' => 'scorm', 'label' => 'SCORM enabled', @@ -54,33 +83,38 @@ class Quiz extends CubistMagicAbstractModel 'column' => true, 'tab' => 'Settings']); + $this->addField(['name' => 'threshold', + 'label' => 'Passed threshold', + 'type' => 'Integer', + 'min' => 0, + 'max' => 100, + 'hint' => 'Over this score (out of 100), the quiz is passed. Set 0 to disable', + 'tab' => 'Settings']); + $this->addField(['name' => 'review', 'label' => 'Enable answer review', 'hint' => 'Let the user review his answers and the correct ones at the end of the quiz', 'type' => 'Checkbox', 'tab' => 'Settings']); - $this->addField(['name' => 'locale', - 'label' => 'Quiz language', - 'type' => 'Locale', - 'column' => true, + $this->addField(['name' => 'passedAction', + 'label' => 'Run code when passing the quiz', + 'hint' => 'JavaScript code', + 'type' => 'Textarea', 'tab' => 'Settings']); - $this->addField([ - 'name' => 'questions', - 'type' => 'BunchOfFieldsMultiple', - 'bunch' => 'App\SubForms\Question', - 'label' => '', - 'add_label' => 'Add question', - 'tab' => 'Questions / Answers', - ]); + $this->addField(['name' => 'failedAction', + 'label' => 'Run code when failing the quiz', + 'hint' => 'JavaScript code', + 'type' => 'Textarea', + 'tab' => 'Settings']); $colors = [ - 'mainColor' => ['label' => 'Main color', 'hint' => 'Buttons and rollovers color'], - 'overlay' => ['label' => 'Overlay', 'hint' => 'Overlay set on the banner'], - 'okColor' => ['label' => 'OK color', 'hint' => 'Color of the ok badge (usually green)'], - 'nokColor' => ['label' => 'NOK color', 'hint' => 'Color of the not ok badge (usually red)'], - 'reviewBackground' => ['label' => 'Review panel background color'], + 'mainColor' => ['label' => 'Main color', 'hint' => 'Buttons and rollovers color', 'value' => '#e7007a'], + 'overlay' => ['label' => 'Overlay', 'hint' => 'Overlay set on the banner', 'value' => 'rgba(0,0,0,0.75)'], + 'reviewBackground' => ['label' => 'Review panel background color', 'value' => '#262626'], + 'okColor' => ['label' => 'OK color', 'hint' => 'Color of the ok badge (usually green)', 'value' => '#66c924'], + 'nokColor' => ['label' => 'NOK color', 'hint' => 'Color of the not ok badge (usually red)', 'value' => '#c61e35'], ]; $default = ['tab' => 'Theme', 'type' => 'Color']; diff --git a/app/Models/QuizTranslation.php b/app/Models/QuizTranslation.php index 9bd31d7a0..062ee8539 100644 --- a/app/Models/QuizTranslation.php +++ b/app/Models/QuizTranslation.php @@ -31,5 +31,16 @@ class QuizTranslation extends CubistMagicAbstractModel 'label' => 'Translation of « ' . $default . ' »', 'type' => 'Text']); } + + $messages = ['defaultMessage' => 'Message displayed at the end of the quiz', + 'passedMessage' => 'Message displayed when passing the quiz', + 'failedMessage' => 'Message displayed when failing the quiz']; + + foreach ($messages as $name => $label) { + $this->addField([ + 'name' => $name, + 'label' => $label, + 'type' => 'Text']); + } } } diff --git a/public/packages/cubist/fluidbooktoolbox/css/style.less b/public/packages/cubist/fluidbooktoolbox/css/style.less index 3ca1af6ac..42a2c5603 100644 --- a/public/packages/cubist/fluidbooktoolbox/css/style.less +++ b/public/packages/cubist/fluidbooktoolbox/css/style.less @@ -11,3 +11,7 @@ display: none; } } + +.help-block{ + opacity: 0.5; +} -- 2.39.5