]> _ Git - fluidbook-toolbox.git/commitdiff
wip #3924 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Oct 2020 17:56:27 +0000 (19:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Oct 2020 17:56:27 +0000 (19:56 +0200)
app/Models/Quiz.php
app/SubForms/Question.php

index c83cab6d37dfd93d326357331ce04b0b7150888a..50641defb0f4c82a1a3e80f82589d05e6b41b75e 100644 (file)
@@ -146,6 +146,13 @@ class Quiz extends CubistMagicAbstractModel
             'default' => true,
             'tab' => 'Settings']);
 
+        $this->addField(['name' => 'logattempts',
+            'label' => 'Enable logging of users attempts',
+            'hint' => 'All users attempts will be sent to the toolbox server',
+            'type' => 'Checkbox',
+            'default' => false,
+            'tab' => 'Settings']);
+
         foreach (self::$_actions as $action => $label) {
             $this->addField(['name' => $action,
                 'label' => $label,
@@ -212,6 +219,7 @@ class Quiz extends CubistMagicAbstractModel
         $xml->addChild('threshold', $this->getAttribute('threshold') ?: '0');
         $xml->addChild('instantReview', $this->getAttribute('instantReview') ? '1' : '0');
         $xml->addChild('review', $this->getAttribute('review') ? '1' : '0');
+        $xml->addChild('logattempts', $this->getAttribute('logattempts') ? '1' : '0');
         $xt = $xml->addChild('translations');
         /** @var QuizTranslation $translation */
         $tid = $this->getAttribute('translation') ?? 1;
@@ -237,10 +245,14 @@ class Quiz extends CubistMagicAbstractModel
             if (!isset($question['type'])) {
                 $question['type'] = 'multiple';
             }
+            if (!isset($question['count_for_score'])) {
+                $question['count_for_score'] = true;
+            }
             $xq = $xqs->addChild('question');
             if ($question['multiple']) {
                 $xq->addAttribute('multiple', '1');
             }
+            $xq->addAttribute('count', $question['count_for_score'] ? '1' : '0');
             $xq->addAttribute('type', $question['type']);
             $xq->addChild('label', $question['question']);
             if ($question['type'] === 'multiple') {
index bec644db70702fef88d8321134de0d264dc08f36..6a1fe1115790690c74a2650c13f4e8812dd2f259 100644 (file)
@@ -24,6 +24,11 @@ class Question extends SubForm
                 'textarea' => 'Long text',
                 'email' => 'E-mail']]);
 
+        $this->addField(['name' => 'count_for_score',
+            'label' => 'Count for score calculation',
+            'type' => 'Checkbox',
+            'default' => true]);
+
         $this->addField(['name' => 'placeholder',
             'type' => 'Text',
             'label' => 'Placeholder',
@@ -42,6 +47,15 @@ class Question extends SubForm
             'when' => ['type' => 'multiple']
         ]);
 
+        $this->addField([
+            'name' => 'min_score',
+            'type' => 'Integer',
+            'label' => 'Minimum score to pass',
+            'hint' => '0 means that all correct answers and only correct answers must be checked in order the user passes the question.',
+            'default' => 0,
+            'when' => ['type' => 'multiple', 'multiple' => 1]
+        ]);
+
         $this->addField([
             'name' => 'answers',
             'type' => 'BunchOfFieldsMultiple',
@@ -50,5 +64,7 @@ class Question extends SubForm
             'label' => 'Answers',
             'when' => ['type' => 'multiple']
         ]);
+
+
     }
 }