public static function CourseObjectQuiz::context in Course 8.2
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::context()
- 3.x modules/course_quiz/src/Plugin/course/CourseObject/CourseObjectQuiz.php \Drupal\course_quiz\Plugin\course\CourseObject\CourseObjectQuiz::context()
Course context handler callback.
Overrides CourseObject::context
File
- modules/
course_quiz/ src/ Plugin/ course/ CourseObject/ CourseObjectQuiz.php, line 27
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
public static function context() {
$route_match = Drupal::routeMatch();
if (in_array($route_match
->getRouteName(), [
'entity.quiz.canonical',
'quiz.take',
'quiz.question.feedback',
'quiz.question.take',
])) {
$quiz = $route_match
->getParameter('quiz');
if ($courseObject = course_get_course_object('quiz', $quiz
->id())) {
return array(
'object_type' => 'quiz',
'instance' => $quiz
->id(),
);
}
}
}