]> _ Git - fluidbook-toolbox.git/commitdiff
done #3438 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Mar 2020 15:34:03 +0000 (16:34 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Mar 2020 15:34:03 +0000 (16:34 +0100)
app/Models/Quiz.php
app/Models/QuizTranslation.php
public/packages/cubist/fluidbooktoolbox/css/style.less

index 8d44a61a0858e2a404b83a486b39a4c747a8805a..ab39b96c2b825ba2956f4f76a15ca8fd2b53cc72 100644 (file)
@@ -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'];
index 9bd31d7a0d7f6a0201489a5751f2c781e15095b0..062ee8539199869b527f5c372a8dd2d51143facd 100644 (file)
@@ -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']);
+        }
     }
 }
index 3ca1af6acf6a47cf8f9f0707f042028de5dbe62d..42a2c560309662a7e4e8cebb3f85d72d1d15cc51 100644 (file)
@@ -11,3 +11,7 @@
         display: none;
     }
 }
+
+.help-block{
+    opacity: 0.5;
+}