From da8fc7640da583384f40308b6d5b973659ecc01d Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 6 Sep 2023 21:52:13 +0100 Subject: [PATCH] MDL-71955 h5p: ensure embedded player sets up $PAGE correctly. For module context, it should set the current cm and course to ensure consistency in navigation API. --- h5p/embed.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/h5p/embed.php b/h5p/embed.php index 779b3256ce9..c2ff803d292 100644 --- a/h5p/embed.php +++ b/h5p/embed.php @@ -51,7 +51,15 @@ try { if (empty($messages->error) && empty($messages->exception)) { // Configure page. - $PAGE->set_context($h5pplayer->get_context()); + $context = $h5pplayer->get_context(); + if ($context instanceof context_module) { + [$course, $cm] = get_course_and_cm_from_cmid($context->instanceid); + $PAGE->set_cm($cm, $course); + $PAGE->activityheader->disable(); + } else { + $PAGE->set_context($context); + } + $PAGE->set_title($h5pplayer->get_title()); $PAGE->set_heading($h5pplayer->get_title());