function CourseObjectQuiz::createInstance in Course 3.x
Same name and namespace in other branches
- 8.3 modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::createInstance()
- 8.2 modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::createInstance()
Create the quiz node and set it as this object's instance.
Overrides CourseObject::createInstance
File
- modules/
course_quiz/ src/ Plugin/ course/ CourseObject/ CourseObjectQuiz.php, line 50
Class
- CourseObjectQuiz
- Plugin annotation @CourseObject( id = "quiz", label = "Quiz", handlers = { "fulfillment" = "\Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuizFulfillment" } )
Namespace
Drupal\course_quiz\Plugin\course\CourseObjectCode
function createInstance() {
$quiz = Quiz::create([
'title' => $this
->getTitle(),
'type' => 'quiz',
]);
$quiz
->save();
$this
->setInstanceId($quiz
->id());
}