public function QuizAccessTestCase::testQuizTakerAnswerScore in Quiz 7.5
Test quiz takers being able to grade their own results.
File
- tests/
QuizAccessTestCase.test, line 59 - Unit tests for the quiz question Module.
Class
- QuizAccessTestCase
- Test aspects of quiz access and permissions.
Code
public function testQuizTakerAnswerScore() {
$question_node = $this
->drupalCreateNode(array(
'type' => 'short_answer',
'title' => 'SA 1 title',
'correct_answer_evaluation' => ShortAnswerQuestion::ANSWER_MANUAL,
'correct_answer' => 1,
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => 'SA 1 body text',
),
),
),
));
$quiz_node = $this
->linkQuestionToQuiz($question_node);
$grader = $this
->drupalCreateUser(array(
'score taken quiz answer',
'view own quiz results',
));
$this
->drupalLogin($grader);
$this
->drupalGet("node/{$quiz_node->nid}/take");
$this
->drupalPost(NULL, array(
"question[{$question_node->nid}][answer]" => 'bluish',
), t('Finish'));
// Score.
$this
->drupalGet("node/{$quiz_node->nid}/quiz/results/1/view");
$this
->drupalPost(NULL, array(
'question[0][score]' => 5,
), t('Save score'));
}