You are here

public function QuizAccessTestCase::testQuizOwnerResultEdit in Quiz 7.5

Test quiz authors being able to score results for own quiz.

File

tests/QuizAccessTestCase.test, line 29
Unit tests for the quiz question Module.

Class

QuizAccessTestCase
Test aspects of quiz access and permissions.

Code

public function testQuizOwnerResultEdit() {
  $grader = $this
    ->drupalCreateUser(array(
    'score own quiz',
    'view results for own quiz',
  ));
  $question_node = $this
    ->drupalCreateNode(array(
    'type' => 'short_answer',
    'title' => 'SA 1 title',
    'correct_answer_evaluation' => ShortAnswerQuestion::ANSWER_MANUAL,
    'correct_answer' => 'blue',
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 'SA 1 body text',
        ),
      ),
    ),
  ));
  $quiz_node = $this
    ->drupalCreateQuiz(array(
    'uid' => $grader->uid,
  ));
  $this
    ->linkQuestionToQuiz($question_node, $quiz_node);
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet("node/{$quiz_node->nid}/take");
  $this
    ->drupalPost(NULL, array(
    "question[{$question_node->nid}][answer]" => 'bluish',
  ), t('Finish'));

  // Score.
  $this
    ->drupalLogin($grader);
  $this
    ->drupalGet("node/{$quiz_node->nid}/quiz/results/1/view");
  $this
    ->drupalPost(NULL, array(
    'question[0][score]' => 5,
  ), t('Save score'));
}