You are here

public function MultichoiceTestCase::testQuestionFeedback in Quiz 7.6

Same name and namespace in other branches
  1. 7.5 question_types/multichoice/multichoice.test \MultichoiceTestCase::testQuestionFeedback()

File

question_types/multichoice/multichoice.test, line 86
Test suite for choice Questions type module.

Class

MultichoiceTestCase
Test class for multichoice questions.

Code

public function testQuestionFeedback() {
  $this
    ->drupalLogin($this->admin);
  $question_node = $this
    ->testCreateQuizQuestion();
  $quiz_node = $this
    ->linkQuestionToQuiz($question_node);

  // Login as non-admin.
  $this
    ->drupalLogin($this->user);

  // Test incorrect question. Feedback, answer.
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer][user_answer]" => $question_node->alternatives[1]['id'],
  ), 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');
}