public function QuizMultichoiceTestCase::testQuestionFeedback in Quiz 6.x
Same name and namespace in other branches
- 8.6 question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php \Drupal\Tests\quiz_multichoice\Functional\QuizMultichoiceTestCase::testQuestionFeedback()
- 8.5 question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php \Drupal\Tests\quiz_multichoice\Functional\QuizMultichoiceTestCase::testQuestionFeedback()
File
- question_types/
quiz_multichoice/ tests/ src/ Functional/ QuizMultichoiceTestCase.php, line 73
Class
- QuizMultichoiceTestCase
- Test multiple choice questions.
Namespace
Drupal\Tests\quiz_multichoice\FunctionalCode
public function testQuestionFeedback() {
$this
->drupalLogin($this->admin);
$question = $this
->testCreateQuizQuestion();
$quiz = $this
->linkQuestionToQuiz($question);
// Login as non-admin.
$this
->drupalLogin($this->user);
// Test incorrect question. Feedback, answer.
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->drupalPostForm(NULL, [
"question[{$question->id()}][answer][user_answer]" => 2,
], t('Finish'));
$this
->assertPattern('/quiz-score-icon selected/', 'Found selected answer.');
$this
->assertPattern('/quiz-score-icon should/', 'Found should answer.');
$this
->assertPattern('/quiz-score-icon incorrect/', 'Found incorrect answer.');
$this
->assertText('You did not choose A');
$this
->assertText('You chose B');
$this
->assertText('You did not choose C');
}