You are here

public function QuizTestBase::createQuiz in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 tests/src/Functional/QuizTestBase.php \Drupal\Tests\quiz\Functional\QuizTestBase::createQuiz()
  2. 6.x tests/src/Functional/QuizTestBase.php \Drupal\Tests\quiz\Functional\QuizTestBase::createQuiz()

Create a quiz with all end feedback settings enabled by default.

Return value

Quiz

41 calls to QuizTestBase::createQuiz()
MatchingTestCase::testChoicePenalty in question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php
Test if the penalty system for guessing wrong work.
MatchingTestCase::testTakeQuestion in question_types/quiz_matching/tests/src/Functional/MatchingTestCase.php
Test using a matching question inside a quiz.
QuizAccessTest::testQuizOwnerResultEdit in tests/src/Functional/QuizAccessTest.php
Test quiz authors being able to score results for own quiz.
QuizBuildOnLastTest::testBuildOnLastAttempt in tests/src/Functional/QuizBuildOnLastTest.php
Test the build on last attempt functionality.
QuizCategorizedRandomTest::testCategorizedRandomQuestions in tests/src/Functional/QuizCategorizedRandomTest.php
Test pulling questions from categories.

... See full list

File

tests/src/Functional/QuizTestBase.php, line 86

Class

QuizTestBase
Base test class for Quiz questions.

Namespace

Drupal\Tests\quiz\Functional

Code

public function createQuiz($settings = array()) {
  $settings += array(
    'title' => 'Quiz',
    'body' => 'Quiz description',
    'type' => 'quiz',
    'result_type' => 'quiz_result',
    'review_options' => array(
      'end' => array_combine(array_keys(quiz_get_feedback_options()), array_keys(quiz_get_feedback_options())),
    ),
  );
  $quiz = Quiz::create($settings);
  $quiz
    ->save();
  return $quiz;
}