public function QuizTestBase::linkQuestionToQuiz in Quiz 6.x
Same name and namespace in other branches
- 8.6 tests/src/Functional/QuizTestBase.php \Drupal\Tests\quiz\Functional\QuizTestBase::linkQuestionToQuiz()
- 8.5 tests/src/Functional/QuizTestBase.php \Drupal\Tests\quiz\Functional\QuizTestBase::linkQuestionToQuiz()
Link a question to a new or provided quiz.
Parameters
QuizQuestion $quiz_question: A quiz question.
Quiz $quiz: A Quiz, or NULL to create one.
Return value
Quiz The quiz.
69 calls to QuizTestBase::linkQuestionToQuiz()
- LongAnswerTestCase::testEditQuestionResponse in question_types/
quiz_long_answer/ tests/ src/ Functional/ LongAnswerTestCase.php - Test that the question response can be edited.
- LongAnswerTestCase::testFilterFormats in question_types/
quiz_long_answer/ tests/ src/ Functional/ LongAnswerTestCase.php - Test that rubric and answer filter settings are respected.
- LongAnswerTestCase::testGradeAnswerManualFeedback in question_types/
quiz_long_answer/ tests/ src/ Functional/ LongAnswerTestCase.php - Test manually graded questions.
- LongAnswerTestCase::testViews in question_types/
quiz_long_answer/ tests/ src/ Functional/ LongAnswerTestCase.php - Test that the question response can be exported.
- MatchingTestCase::testChoicePenalty in question_types/
quiz_matching/ tests/ src/ Functional/ MatchingTestCase.php - Test if the penalty system for guessing wrong work.
File
- tests/
src/ Functional/ QuizTestBase.php, line 70
Class
- QuizTestBase
- Base test class for Quiz questions.
Namespace
Drupal\Tests\quiz\FunctionalCode
public function linkQuestionToQuiz(QuizQuestion $quiz_question, Quiz $quiz = NULL) {
static $weight = 0;
if (!$quiz) {
// Create a new quiz with defaults.
$quiz = $this
->createQuiz();
}
// Test helper - weight questions one after another.
$quiz
->addQuestion($quiz_question)
->set('weight', $weight)
->save();
$weight++;
return $quiz;
}