public function MatchingTestCase::testCreateQuizQuestion 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::testCreateQuizQuestion()
- 6.x question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php \Drupal\Tests\quiz_matching\Functional\MatchingTestCase::testCreateQuizQuestion()
Test adding and taking a matching question.
3 calls to MatchingTestCase::testCreateQuizQuestion()
- MatchingTestCase::testChoicePenalty in question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php - Test if the penalty system for guessing wrong work.
- MatchingTestCase::testEditQuestionResponse in question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php - Test that the question response is prefilled and can be edited.
- MatchingTestCase::testTakeQuestion in question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php - Test using a matching question inside a quiz.
File
- question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php, line 20
Class
- MatchingTestCase
- Test class for matching questions.
Namespace
Drupal\Tests\quiz_matching\FunctionalCode
public function testCreateQuizQuestion($settings = []) {
// Login as our privileged user.
$this
->drupalLogin($this->admin);
$question_node = $this
->createQuestion($settings + array(
'type' => 'matching',
'title' => 'MA 1 title',
'body' => 'MA 1 body text',
'choice_penalty' => 0,
));
for ($i = 0; $i <= 2; $i++) {
//$match[$i]['question'] = $match[$i]['answer'] = $match[$i]['feedback'] = "MAF " . ($i + 1);
// Set up some alternatives.
$a = Paragraph::create([
'type' => 'quiz_matching',
'matching_question' => "MAQ " . ($i + 1),
'matching_answer' => "MAA " . ($i + 1),
]);
$a
->save();
$question_node
->get('quiz_matching')
->appendItem($a);
}
$question_node
->save();
return $question_node;
}