From fda49855b8d13417c116e8b4a174d24657476b87 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 27 Nov 2025 17:29:13 +0800 Subject: [PATCH] MDL-85858 mod_scorm: Set page and iframe titles for the SCORM player --- public/mod/scorm/module.js | 1 + public/mod/scorm/player.php | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/public/mod/scorm/module.js b/public/mod/scorm/module.js index ef0fff59658..48afdea15ff 100644 --- a/public/mod/scorm/module.js +++ b/public/mod/scorm/module.js @@ -192,6 +192,7 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h obj.setAttribute('allowfullscreen', 'allowfullscreen'); obj.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen'); obj.setAttribute('mozallowfullscreen', 'mozallowfullscreen'); + obj.setAttribute('title', toc_title); if (!window_name && node.title != null) { obj.setAttribute('src', url_prefix + node.title); } diff --git a/public/mod/scorm/player.php b/public/mod/scorm/player.php index 5962d310807..c5ae795d00c 100644 --- a/public/mod/scorm/player.php +++ b/public/mod/scorm/player.php @@ -106,12 +106,19 @@ $strexit = get_string('exitactivity', 'scorm'); $coursecontext = context_course::instance($course->id); +$scormname = format_string($scorm->name); +if ($mode === 'browse') { + $scormname = get_string('browsemodewithname', 'scorm', $scormname); +} +$titleparts = [ + $scormname, + format_string($course->shortname, true, ['context' => $coursecontext]), +]; +$PAGE->set_title(implode(moodle_page::TITLE_SEPARATOR, $titleparts)); + if ($displaymode == 'popup') { $PAGE->set_pagelayout('embedded'); } else { - $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); - $pagetitle = strip_tags("$shortname: ".format_string($scorm->name)); - $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', context_module::instance($cm->id))) { @@ -258,8 +265,15 @@ if ($result->prerequisites) { js_writer::function_call('scorm_openpopup', Array($url->out(false), $name, $scorm->options, $scorm->width, $scorm->height))); - echo html_writer::tag('noscript', html_writer::tag('iframe', '', array('id' => 'main', - 'class' => 'scoframe', 'name' => 'main', 'src' => 'loadSCO.php?id='.$cm->id.$scoidstr.$modestr))); + $frametitle = $result->toctitle ?? get_string('contents', 'scorm'); + $iframe = html_writer::tag('iframe', '', [ + 'id' => 'main', + 'class' => 'scoframe', + 'name' => 'main', + 'src' => 'loadSCO.php?id=' . $cm->id . $scoidstr . $modestr, + 'title' => $frametitle, + ]); + echo html_writer::tag('noscript', $iframe); } } else { echo $OUTPUT->box(get_string('noprerequisites', 'scorm'));