]> _ Git - fluidbook-toolbox.git/commitdiff
wait #4182 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 11 Jan 2021 12:45:42 +0000 (13:45 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 11 Jan 2021 12:45:42 +0000 (13:45 +0100)
app/Models/Quiz.php
resources/quiz/js/main.js

index 32ead26ebdf4641f7f289fa0801b25a240be4ee0..53500f6b2c517aa3d093617ca5a96ff70562870a 100644 (file)
@@ -142,6 +142,13 @@ class Quiz extends CubistMagicAbstractModel
             'column' => true,
             'tab' => __('Paramètres')]);
 
+        $this->addField(['name' => 'display_score',
+            'label' => __('Afficher le score'),
+            'type' => 'Checkbox',
+            'default' => true,
+            'tab' => __('Paramètres'),
+        ]);
+
         $this->addField(['name' => 'threshold',
             'label' => __('Seuil de réussite'),
             'type' => 'Integer',
@@ -258,6 +265,7 @@ class Quiz extends CubistMagicAbstractModel
         $xml->addChild('restart_button', $data->get('restart_button', '0') ? '1' : '0');
         $xml->addChild('instantReview', $data->get('instantReview', true) ? '1' : '0');
         $xml->addChild('review', $data->get('review', 'always'));
+        $xml->addChild('display_score', $data->get('display_score', true) ? '1' : '0');
         $xml->addChild('logattempts', $data->get('logattempts', false) ? '1' : '0');
         $xt = $xml->addChild('translations');
         /** @var QuizTranslation $translation */
index 3b60c177380c3a79f69aefa18c85084ab015d6ce..11f1a291cbb6cbbb411fbcef6409d23b102e193e 100644 (file)
@@ -97,6 +97,7 @@
             threshold = 0;
             instantReview = $(data).find('instantReview').text() === '1';
             logAttempts = $(data).find('logattempts').text() === '1';
+            displayScore = $(data).find('display_score').text() === '1';
 
             if ($(data).find('threshold').length > 0 && !isNaN(parseFloat($(data).find('threshold').text()))) {
                 threshold = parseFloat($(data).find('threshold').text());
             passedAction = $(data).find('passedAction').length > 0 && $(data).find('passedAction').text() !== '' ? $(data).find('passedAction').text() : null;
             failedAction = $(data).find('failedAction').length > 0 && $(data).find('failedAction').text() !== '' ? $(data).find('failedAction').text() : null;
 
-            var results = $('<section id="resultsscreen"><div id="results">' +
-                '<h2 class="defaultMessage">' + defaultMessage + '</h2>' +
-                '<h2 class="passedMessage">' + passedMessage + '</h2>' +
-                '<h2 class="failedMessage">' + failedMessage + '</h2>' +
-                '<div class="content">' + getTranslation('totalQuestions') + ' <span id="totalquestions">' + countQuestions + '</span><br />' + getTranslation('correctAnswers') + ' <span id="correctanswers"></span></div></div>' +
-                '<a href=""  id="restart" class="button">' + getTranslation('restartQuiz') + '</a>' +
-                '</section>');
+            var results = '<section id="resultsscreen">';
+            results += '<div id="results">';
+            results += '<h2 class="defaultMessage">' + defaultMessage + '</h2>';
+            results += '<h2 class="passedMessage">' + passedMessage + '</h2>';
+            results += '<h2 class="failedMessage">' + failedMessage + '</h2>';
+            if(displayScore) {
+                results += '<div class="content">' + getTranslation('totalQuestions') + ' <span id="totalquestions">' + countQuestions + '</span><br />' + getTranslation('correctAnswers') + ' <span id="correctanswers"></span></div>';
+            }
+            results += '</div>';
+            results += '<a href=""  id="restart" class="button">' + getTranslation('restartQuiz') + '</a>';
+            results += '</section>';
+
+            results = $(results);
             $(results).append(correction);
 
             $("main").append(results);