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