From 96d41a501beacf3610ba105fdee1d89b9380e68a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 12 Oct 2020 19:56:27 +0200 Subject: [PATCH] wip #3924 @1 --- app/Models/Quiz.php | 12 ++++++++++++ app/SubForms/Question.php | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index c83cab6d3..50641defb 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -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') { diff --git a/app/SubForms/Question.php b/app/SubForms/Question.php index bec644db7..6a1fe1115 100644 --- a/app/SubForms/Question.php +++ b/app/SubForms/Question.php @@ -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'] ]); + + } } -- 2.39.5