From: Vincent Vanwaelscappel Date: Tue, 13 Oct 2020 17:26:14 +0000 (+0200) Subject: done #3948 @2.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1bb3169d7660dd506d031030541a9f7fdf3176ac;p=fluidbook-toolbox.git done #3948 @2.5 --- diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 8e67d3f12..571a21646 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -224,7 +224,7 @@ class Quiz extends CubistMagicAbstractModel $xml->addChild('logattempts', $data->get('logattempts', false) ? '1' : '0'); $xt = $xml->addChild('translations'); /** @var QuizTranslation $translation */ - $tid = $data->get('translation',1) ?? 1; + $tid = $data->get('translation', 1) ?? 1; if ($tid === 'en') { $tid = 1; } @@ -256,6 +256,7 @@ class Quiz extends CubistMagicAbstractModel } $xq->addAttribute('count', $question['count_for_score'] ? '1' : '0'); $xq->addAttribute('type', $question['type']); + $xq->addAttribute('min_score', $question['min_score']); $xq->addChild('label', $question['question']); if ($question['type'] === 'multiple') { $xas = $xq->addChild('answers'); diff --git a/resources/quiz/js/main.js b/resources/quiz/js/main.js index b09ae217b..f1960d4a2 100644 --- a/resources/quiz/js/main.js +++ b/resources/quiz/js/main.js @@ -115,7 +115,7 @@ 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 += '
'; @@ -390,16 +390,20 @@ }; if ($(this).data('type') === 'multiple') { + var min_score = parseInt($(this).data('min-score')); + if (min_score === 0) { + min_score = $(this).find('.answer[data-correct="1"]').length; + } + var this_score = 0; $(this).find('.answer').each(function () { - var correct = $(this).attr('data-correct') == '1'; - var active = $(this).hasClass('active'); - if (correct !== active) { - ok = false; - } - if (active) { + if ($(this).hasClass('active')) { + var correct = $(this).attr('data-correct') == '1'; + this_score += correct ? 1 : -1; a.push($(this).data('a')) } }); + console.log(this_score, min_score); + ok = this_score >= min_score; answers.push(a); log.anwser = a; } else {