public function QuizMultichoiceTestCase::testEditQuestionResponse 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::testEditQuestionResponse()
- 8.5 question_types/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php \Drupal\Tests\quiz_multichoice\Functional\QuizMultichoiceTestCase::testEditQuestionResponse()
Test that the question response can be edited.
File
- question_types/
quiz_multichoice/ tests/ src/ Functional/ QuizMultichoiceTestCase.php, line 215
Class
- QuizMultichoiceTestCase
- Test multiple choice questions.
Namespace
Drupal\Tests\quiz_multichoice\FunctionalCode
public function testEditQuestionResponse() {
// Create & link a question.
$question = $this
->testCreateQuizQuestion();
$quiz = $this
->linkQuestionToQuiz($question);
$question2 = $this
->testCreateQuizQuestion();
$this
->linkQuestionToQuiz($question2, $quiz);
// Login as non-admin.
$this
->drupalLogin($this->user);
// Take the quiz.
$this
->drupalGet("quiz/{$quiz->id()}/take");
// Test editing a question.
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->drupalGet("quiz/{$quiz->id()}/take/1");
$this
->drupalPostForm(NULL, [
"question[{$question->id()}][answer][user_answer]" => 1,
], t('Next'));
$this
->drupalGet("quiz/{$quiz->id()}/take/1");
$this
->drupalPostForm(NULL, [
"question[{$question->id()}][answer][user_answer]" => 2,
], t('Next'));
}