From bcf93df65818c674731e10ddf016d694fe0c4c85 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 2 Nov 2020 15:21:12 +0100 Subject: [PATCH] wip #4031 @0:40 --- app/Models/Quiz.php | 12 +++++++++++- resources/quiz/js/main.js | 11 ++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index cadee9359..39e963474 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -142,7 +142,17 @@ class Quiz extends CubistMagicAbstractModel $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', + 'type' => 'SelectFromArray', + 'allows_null' => false, + 'options' => [ + 'always' => 'Always', + 'passed' => 'Only if passed', + 'never' => 'Never', + ], + 'options_aliases' => [ + '1' => 'always', + '0' => 'never', + ], 'default' => true, 'tab' => 'Settings']); diff --git a/resources/quiz/js/main.js b/resources/quiz/js/main.js index de4c64e1a..7a7407ecc 100644 --- a/resources/quiz/js/main.js +++ b/resources/quiz/js/main.js @@ -87,7 +87,7 @@ cssVars({}); var rev = $(data).find('review'); - showReview = (rev.length === 0 || rev.text() === '1'); + showReview = rev.text(); threshold = 0; instantReview = $(data).find('instantReview').text() === '1'; logAttempts = $(data).find('logattempts').text() === '1'; @@ -281,10 +281,11 @@ } if ($(next).is("#resultsscreen")) { - if (showReview) { - $('#correction').show(); - } else { + var show = showReview === 'always' || (showReview === 'passed' && checkScore()); + if (show) { $('#correction').hide(); + } else { + $('#correction').show(); } completed(); } @@ -371,7 +372,7 @@ function displayBadge(correct) { resize(); - if (!instantReview || correct===null) { + if (!instantReview || correct === null) { nextScreen(); return; } -- 2.39.5