mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-43247 SCORM: improve pop-up handling and redirect to homepage on close.
This commit is contained in:
parent
f05e25d208
commit
9d22765723
4 changed files with 50 additions and 4 deletions
|
@ -290,6 +290,7 @@ $string['php5'] = 'PHP 5 (DOMXML native library)';
|
||||||
$string['pluginadministration'] = 'SCORM package administration';
|
$string['pluginadministration'] = 'SCORM package administration';
|
||||||
$string['pluginname'] = 'SCORM package';
|
$string['pluginname'] = 'SCORM package';
|
||||||
$string['popup'] = 'New window';
|
$string['popup'] = 'New window';
|
||||||
|
$string['popuplaunched'] = 'This SCORM package has been launched in a popup window, If you have finished viewing this resource, click here to return to the course page';
|
||||||
$string['popupmenu'] = 'In a drop down menu';
|
$string['popupmenu'] = 'In a drop down menu';
|
||||||
$string['popupopen'] = 'Open package in a new window';
|
$string['popupopen'] = 'Open package in a new window';
|
||||||
$string['popupsblocked'] = 'It appears that popup windows are blocked, stopping this SCORM package from playing. Please check your browser settings before trying again.';
|
$string['popupsblocked'] = 'It appears that popup windows are blocked, stopping this SCORM package from playing. Please check your browser settings before trying again.';
|
||||||
|
|
|
@ -822,7 +822,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||||
$organization = optional_param('organization', '', PARAM_INT);
|
$organization = optional_param('organization', '', PARAM_INT);
|
||||||
|
|
||||||
if ($scorm->displaycoursestructure == 1) {
|
if ($scorm->displaycoursestructure == 1) {
|
||||||
echo $OUTPUT->box_start('generalbox boxaligncenter toc');
|
echo $OUTPUT->box_start('generalbox boxaligncenter toc', 'toc');
|
||||||
?>
|
?>
|
||||||
<div class="structurehead"><?php print_string('contents', 'scorm') ?></div>
|
<div class="structurehead"><?php print_string('contents', 'scorm') ?></div>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -25,10 +25,53 @@ M.mod_scormform.init = function(Y) {
|
||||||
poptions = poptions+',width='+cwidth+',height='+cheight;
|
poptions = poptions+',width='+cwidth+',height='+cheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launch == true) {
|
var scormredirect = function (winobj) {
|
||||||
launch_url = launch_url+"&display=popup";
|
winobj.onload = function () {
|
||||||
window.open(launch_url,'Popup', poptions);
|
|
||||||
|
// Hide the form and toc if it exists - we don't want to allow multiple submissions when a window is open.
|
||||||
|
if (scormform) {
|
||||||
|
scormform.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
var scormtoc = Y.one('#toc');
|
||||||
|
if (scormtoc) {
|
||||||
|
scormtoc.hide();
|
||||||
|
}
|
||||||
|
// Hide the intro and display a message to the user if the window is closed but for some reason the events
|
||||||
|
// below aren't triggered.
|
||||||
|
var scormintro = Y.one('#intro');
|
||||||
|
scormintro.setHTML('<a href="'+ course_url + '">' + M.str.scorm.popuplaunched + '</a>');
|
||||||
|
}
|
||||||
|
// When pop-up is closed return to course homepage.
|
||||||
|
winobj.onunload = function () {
|
||||||
|
// Onunload is called multiple times in the SCORM window - we only want to handle when it is actually closed.
|
||||||
|
setTimeout(function() {
|
||||||
|
if (!winobj.opener) {
|
||||||
|
// Redirect the parent window to the course homepage.
|
||||||
parent.window.location = course_url;
|
parent.window.location = course_url;
|
||||||
}
|
}
|
||||||
scormform.onsubmit = function() {window.open('', 'Popup', poptions); this.target='Popup'; parent.window.location = course_url;};
|
}, 200)
|
||||||
|
}
|
||||||
|
// Check to make sure pop-up has been launched - if not display a warning,
|
||||||
|
// this shouldn't happen as the pop-up here is launched on user action but good to make sure.
|
||||||
|
setTimeout(function() {
|
||||||
|
if (!winobj) {
|
||||||
|
scormintro.setHTML(M.str.scorm.popupsblocked);
|
||||||
|
}}, 800);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (launch == true) {
|
||||||
|
launch_url = launch_url+"&display=popup";
|
||||||
|
var winobj = window.open(launch_url,'Popup', poptions);
|
||||||
|
this.target='Popup';
|
||||||
|
scormredirect(winobj);
|
||||||
|
}
|
||||||
|
// Listen for view form submit and generate popup on user interaction.
|
||||||
|
if (scormform) {
|
||||||
|
scormform.onsubmit = function() {
|
||||||
|
var winobj = window.open('', 'Popup', poptions);
|
||||||
|
this.target='Popup';
|
||||||
|
scormredirect(winobj);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ if (!empty($scorm->popup)) {
|
||||||
'cwidth' => $scorm->width,
|
'cwidth' => $scorm->width,
|
||||||
'cheight' => $scorm->height,
|
'cheight' => $scorm->height,
|
||||||
'popupoptions' => $scorm->options), true);
|
'popupoptions' => $scorm->options), true);
|
||||||
|
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
|
||||||
|
$PAGE->requires->string_for_js('popuplaunched', 'scorm');
|
||||||
$PAGE->requires->js('/mod/scorm/view.js', true);
|
$PAGE->requires->js('/mod/scorm/view.js', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue