public function MatchingTestCase::testChoicePenalty in Quiz 8.6
Same name and namespace in other branches
- 8.5 question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php \Drupal\Tests\quiz_matching\Functional\MatchingTestCase::testChoicePenalty()
- 6.x question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php \Drupal\Tests\quiz_matching\Functional\MatchingTestCase::testChoicePenalty()
Test if the penalty system for guessing wrong work.
File
- question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php, line 116
Class
- MatchingTestCase
- Test class for matching questions.
Namespace
Drupal\Tests\quiz_matching\FunctionalCode
public function testChoicePenalty() {
$quiz_node = $this
->createQuiz(array(
'review_options' => array(
'end' => array_combine([
'answer_feedback',
'score',
], [
'answer_feedback',
'score',
]),
),
));
$question_node = $this
->testCreateQuizQuestion([
'choice_penalty' => 1,
]);
// Link the question.
$this
->linkQuestionToQuiz($question_node, $quiz_node);
// Login as non-admin.
$this
->drupalLogin($this->user);
// Test penalty.
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
$this
->drupalPostForm(NULL, array(
"question[{$question_node->id()}][answer][user_answer][1]" => 1,
"question[{$question_node->id()}][answer][user_answer][2]" => 1,
"question[{$question_node->id()}][answer][user_answer][3]" => 3,
), t('Finish'));
$this
->assertText('You got 1 of 3 possible points.');
}