function MultichoiceTestCase::testMultipleAnswers in Quiz 7.6
Same name and namespace in other branches
- 7.5 question_types/multichoice/multichoice.test \MultichoiceTestCase::testMultipleAnswers()
Test multiple answers.
File
- question_types/
multichoice/ multichoice.test, line 111 - Test suite for choice Questions type module.
Class
- MultichoiceTestCase
- Test class for multichoice questions.
Code
function testMultipleAnswers() {
$this
->drupalLogin($this->admin);
$question_node = $this
->testCreateQuizQuestion(array(
'choice_multi' => 1,
));
$quiz_node = $this
->linkQuestionToQuiz($question_node);
$this
->drupalLogin($this->user);
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node->nid}][answer][user_answer][1]" => 1,
"question[{$question_node->nid}][answer][user_answer][3]" => 3,
), t('Finish'));
// 0 of 1, because user picked a correct answer and an incorrect answer.
$this
->assertText('You got 0 of 1 possible points.');
$this
->assertText('Your score: 0%');
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node->nid}][answer][user_answer][1]" => 1,
), t('Finish'));
// 1 of 1, because user picked a correct answer and not an incorrect answer.
$this
->assertText('You got 1 of 1 possible points.');
$this
->assertText('Your score: 100%');
}