public function QuizTakingTest::testMarkDoubtful in Quiz 8.6
Same name and namespace in other branches
- 8.5 tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testMarkDoubtful()
- 6.x tests/src/Functional/QuizTakingTest.php \Drupal\Tests\quiz\Functional\QuizTakingTest::testMarkDoubtful()
Test the mark doubtful functionality.
File
- tests/
src/ Functional/ QuizTakingTest.php, line 319
Class
- QuizTakingTest
- Test quiz taking behavior.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testMarkDoubtful() {
$this
->drupalLogin($this->admin);
$quiz_node = $this
->createQuiz(array(
'allow_skipping' => 1,
'allow_jumping' => 1,
'mark_doubtful' => 1,
));
// 2 questions.
$question1 = $this
->createQuestion(array(
'type' => 'truefalse',
'truefalse_correct' => 1,
));
$this
->linkQuestionToQuiz($question1, $quiz_node);
$question2 = $this
->createQuestion(array(
'type' => 'directions',
));
$this
->linkQuestionToQuiz($question2, $quiz_node);
// Take the quiz.
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz_node->id()}/take");
// Ensure it is on truefalse.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->assertField("edit-question-{$question1->id()}-is-doubtful");
$this
->drupalPostForm(NULL, array(
"question[{$question1->id()}][answer]" => 1,
"question[{$question1->id()}][is_doubtful]" => 1,
), t('Next'));
// Go back and verify it was saved.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/1");
$this
->assertFieldChecked("edit-question-{$question1->id()}-is-doubtful");
// Ensure it is not on quiz directions.
$this
->drupalGet("quiz/{$quiz_node->id()}/take/2");
$this
->assertNoField("edit-question-{$question2->id()}-is-doubtful");
}