public function MultichoiceTestCase::testSimpleScoring in Quiz 7.5
Same name and namespace in other branches
- 7.6 question_types/multichoice/multichoice.test \MultichoiceTestCase::testSimpleScoring()
Test simple scoring.
File
- question_types/
multichoice/ multichoice.test, line 196 - Test suite for choice Questions type module.
Class
- MultichoiceTestCase
- Test class for multichoice questions.
Code
public function testSimpleScoring() {
$this
->drupalLogin($this->admin);
$settings = array();
$settings['alternatives'][1]['score_if_chosen'] = 0;
$settings['alternatives'][1]['score_if_not_chosen'] = 0;
$settings['choice_multi'] = 1;
$settings['choice_boolean'] = 1;
$question_node = $this
->testCreateQuizQuestion($settings);
$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'));
$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'));
$this
->assertText('You got 1 of 1 possible points.');
$this
->assertText('Your score: 100%');
}