From 1aca49e3cfe1f7ba744cae097ab5e2b13f475053 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 12 Oct 2020 20:51:27 +0200 Subject: [PATCH] wip #3924 @1 --- resources/quiz/js/main.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/resources/quiz/js/main.js b/resources/quiz/js/main.js index 044488820..f21909950 100644 --- a/resources/quiz/js/main.js +++ b/resources/quiz/js/main.js @@ -15,7 +15,6 @@ $(window).on('resize', resize); - function resize() { // Window size that reserve enough space for all questions and avoid scroll jumps var maxHeight = 0; @@ -90,6 +89,8 @@ var rev = $(data).find('review'); showReview = (rev.length === 0 || rev.text() === '1'); threshold = 0; + instantReview = $(data).find('instantReview').text() === '1'; + logAttempts = $(data).find('logattempts').text() === '1'; if ($(data).find('threshold').length > 0 && !isNaN(parseFloat($(data).find('threshold').text()))) { threshold = parseFloat($(data).find('threshold').text()); @@ -110,14 +111,14 @@ var type = $(this).attr('type'); var multiple = $(this).attr('multiple') == '1'; var multipleclass = multiple ? ' multiple' : ''; - var question = '
'; + var question = '
'; question += '

' + sprintf(getTranslation('question'), qn) + '

' + $(this).find('label').text() + '
'; question += '
'; question += '
'; if (multiple) { - question += '' + getTranslation('validateAnswers') + ''; - } else if (type !== 'multiple') { question += '' + getTranslation('validateAnswer') + ''; + } else if (type !== 'multiple') { + question += '' + getTranslation('validateAnswerSingular') + ''; } question += '
'; @@ -280,7 +281,7 @@ TweenMax.fromTo($(prev), 0.5, {left: 0, opacity: 1}, { left: -w - 50, opacity: 0, onComplete: function () { $(prev).hide(); - endTransition(); + endTransition(); } }); resizeContainer(); @@ -297,21 +298,32 @@ setScormValue('cmi.core.lesson_status', 'completed'); setSCORMLocation({q: 1}); - checkScore(); + var passed = checkScore(); + if (logAttempts) { + $.ajax('https://toolbox.fluidbook.com/quizlog/', + { + method: 'post', + data: logdata, + } + ); + } } function checkScore() { - var normalizedScore = score / totalQuestions; $('#results > h2').hide(); + var passed; if (threshold === 0) { $('.defaultMessage').show(); + passed = true; } else if (normalizedScore >= threshold) { $(".passedMessage").show(); execAction(passedAction); + passed = true; } else { $('.failedMessage').show(); execAction(failedAction); + passed = false; } } @@ -328,6 +340,10 @@ function displayBadge(correct) { resize(); + if (!instantReview) { + nextScreen(); + return; + } if (correct) { $("#badge").addClass('correct').removeClass('incorrect'); } else { -- 2.39.5