public function QuizAccessTest::testQuizOwnerResultEdit in Quiz 8.5
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizAccessTest.php \Drupal\Tests\quiz\Functional\QuizAccessTest::testQuizOwnerResultEdit()
- 6.x tests/src/Functional/QuizAccessTest.php \Drupal\Tests\quiz\Functional\QuizAccessTest::testQuizOwnerResultEdit()
Test quiz authors being able to score results for own quiz.
File
- tests/
src/ Functional/ QuizAccessTest.php, line 24 - Unit tests for the quiz question Module.
Class
- QuizAccessTest
- Test aspects of quiz access and permissions.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function testQuizOwnerResultEdit() {
$grader = $this
->drupalCreateUser(array(
'score own quiz',
'view results for own quiz',
));
$question = $this
->createQuestion(array(
'type' => 'short_answer',
'title' => 'SA 1 title',
'correct_answer_evaluation' => ShortAnswerQuestion::ANSWER_MANUAL,
'correct_answer' => 'blue',
'body' => 'SA 1 body text',
));
$quiz = $this
->createQuiz(array(
'uid' => $grader
->id(),
));
$this
->linkQuestionToQuiz($question, $quiz);
$this
->drupalLogin($this->user);
$this
->drupalGet("quiz/{$quiz->id()}/take");
$this
->drupalPostForm(NULL, array(
"question[{$question->id()}][answer]" => 'bluish',
), t('Finish'));
// Score.
$this
->drupalLogin($grader);
$this
->drupalGet("quiz/{$quiz->id()}/result/1/edit");
$this
->drupalPostForm(NULL, array(
"question[{$question->id()}][score]" => 5,
), t('Save score'));
}