mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-28295 SCORM change mangement of pop-up windows, load full SCORM API in existing window - this fixes an issue with IE 7 and httpreq communication
This commit is contained in:
parent
3fdc622697
commit
6d954dd372
6 changed files with 48 additions and 34 deletions
|
@ -555,6 +555,22 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||||
upgrade_mod_savepoint(true, 2011073100, 'scorm');
|
upgrade_mod_savepoint(true, 2011073100, 'scorm');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2011080100) {
|
||||||
|
//MDL-28295 the behaviour of pop-up windows has now changed - it now loads the full Player in the window
|
||||||
|
//because of this, pop-up windows now include the TOC and the nav bar - disabling these for existing SCORMS
|
||||||
|
//as it is a change that most users won't expect.
|
||||||
|
//get all SCORMS that use a new window.
|
||||||
|
require_once($CFG->dirroot."/mod/scorm/lib.php");
|
||||||
|
$rs = $DB->get_recordset('scorm', array('popup' => 1), '', 'id,hidetoc,hidenav');
|
||||||
|
foreach ($rs as $scorm) {
|
||||||
|
$scorm->hidetoc = SCORM_TOC_DISABLED;
|
||||||
|
$scorm->hidenav = 1;
|
||||||
|
$DB->update_record('scorm', $scorm);
|
||||||
|
}
|
||||||
|
$rs->close();
|
||||||
|
|
||||||
|
upgrade_mod_savepoint(true, 2011080100, 'scorm');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
|
||||||
var cwidth = scormplayerdata.cwidth;
|
var cwidth = scormplayerdata.cwidth;
|
||||||
var cheight = scormplayerdata.cheight;
|
var cheight = scormplayerdata.cheight;
|
||||||
var poptions = scormplayerdata.popupoptions;
|
var poptions = scormplayerdata.popupoptions;
|
||||||
scorm_openpopup("loadSCO.php?" + node.title, window_name, poptions, cwidth, cheight);
|
scorm_openpopup(M.cfg.wwwroot + "/mod/scorm/loadSCO.php?" + node.title, window_name, poptions, cwidth, cheight);
|
||||||
} else {
|
} else {
|
||||||
content.replaceChild(obj, old);
|
content.replaceChild(obj, old);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
function scorm_openpopup(url,name,options,width,height) {
|
function scorm_openpopup(url,name,options,width,height) {
|
||||||
fullurl = M.cfg.wwwroot + '/mod/scorm/' + url;
|
windowobj = window.open(url,name,options);
|
||||||
windowobj = window.open(fullurl,name,options);
|
|
||||||
if (!windowobj) {
|
if (!windowobj) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ $scoid = required_param('scoid', PARAM_INT); // sco ID
|
||||||
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
|
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
|
||||||
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
|
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
|
||||||
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
|
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
|
||||||
|
$displaymode = optional_param('display','',PARAM_ALPHA);
|
||||||
|
|
||||||
//IE 6 Bug workaround
|
//IE 6 Bug workaround
|
||||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
|
||||||
|
@ -80,10 +81,14 @@ $strscorm = get_string('modulename', 'scorm');
|
||||||
$strpopup = get_string('popup', 'scorm');
|
$strpopup = get_string('popup', 'scorm');
|
||||||
$strexit = get_string('exitactivity', 'scorm');
|
$strexit = get_string('exitactivity', 'scorm');
|
||||||
|
|
||||||
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
|
|
||||||
$PAGE->set_title($pagetitle);
|
|
||||||
$PAGE->set_heading($course->fullname);
|
|
||||||
|
|
||||||
|
if ($displaymode == 'popup') {
|
||||||
|
$PAGE->set_pagelayout('popup');
|
||||||
|
} else {
|
||||||
|
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
|
||||||
|
$PAGE->set_title($pagetitle);
|
||||||
|
$PAGE->set_heading($course->fullname);
|
||||||
|
}
|
||||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
notice(get_string("activityiscurrentlyhidden"));
|
notice(get_string("activityiscurrentlyhidden"));
|
||||||
|
@ -161,22 +166,17 @@ $completion = new completion_info($course);
|
||||||
$completion->set_module_viewed($cm);
|
$completion->set_module_viewed($cm);
|
||||||
|
|
||||||
// Print the page header
|
// Print the page header
|
||||||
$bodyscript = '';
|
if (empty($scorm->popup) || $displaymode=='popup') {
|
||||||
if ($scorm->popup == 1) {
|
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
|
||||||
$bodyscript = 'onunload="main.close();"';
|
$PAGE->set_button($exitlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
|
|
||||||
|
|
||||||
$PAGE->set_button($exitlink);
|
|
||||||
|
|
||||||
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
|
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
|
||||||
'cheight'=>$scorm->height,
|
'cheight'=>$scorm->height,
|
||||||
'popupoptions' => $scorm->options), true);
|
'popupoptions' => $scorm->options), true);
|
||||||
$PAGE->requires->js('/mod/scorm/request.js', true);
|
$PAGE->requires->js('/mod/scorm/request.js', true);
|
||||||
$PAGE->requires->js('/lib/cookies.js', true);
|
$PAGE->requires->js('/lib/cookies.js', true);
|
||||||
$PAGE->requires->css('/mod/scorm/styles.css');
|
$PAGE->requires->css('/mod/scorm/styles.css');
|
||||||
|
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
|
|
||||||
// NEW IMS TOC
|
// NEW IMS TOC
|
||||||
|
@ -196,15 +196,6 @@ $name = false;
|
||||||
<script id="external-scormapi" type="text/JavaScript"></script>
|
<script id="external-scormapi" type="text/JavaScript"></script>
|
||||||
</div>
|
</div>
|
||||||
<div id="scormtop">
|
<div id="scormtop">
|
||||||
<?php
|
|
||||||
if ($result->prerequisites) {
|
|
||||||
if ($scorm->popup != 0) {
|
|
||||||
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
|
|
||||||
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname', 'scorm') . '</a>';
|
|
||||||
echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode', 'scorm')."</div>\n" : ''; ?>
|
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode', 'scorm')."</div>\n" : ''; ?>
|
||||||
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode', 'scorm')."</div>\n" : ''; ?>
|
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode', 'scorm')."</div>\n" : ''; ?>
|
||||||
<div id="scormnav" class="scorm-right">
|
<div id="scormnav" class="scorm-right">
|
||||||
|
@ -216,7 +207,14 @@ if ($scorm->hidetoc == SCORM_TOC_POPUP) {
|
||||||
</div> <!-- Scormnav -->
|
</div> <!-- Scormnav -->
|
||||||
</div> <!-- Scormtop -->
|
</div> <!-- Scormtop -->
|
||||||
<div id="toctree" class="generalbox">
|
<div id="toctree" class="generalbox">
|
||||||
<?php echo $result->toc; ?>
|
<?php
|
||||||
|
if (empty($scorm->popup) || $displaymode == 'popup') {
|
||||||
|
echo $result->toc;
|
||||||
|
} else {
|
||||||
|
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
|
||||||
|
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname', 'scorm') . '</a>';
|
||||||
|
echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
|
||||||
|
}?>
|
||||||
</div> <!-- toctree -->
|
</div> <!-- toctree -->
|
||||||
</div> <!-- tocbox -->
|
</div> <!-- tocbox -->
|
||||||
<noscript>
|
<noscript>
|
||||||
|
@ -227,7 +225,7 @@ if ($scorm->hidetoc == SCORM_TOC_POPUP) {
|
||||||
</noscript>
|
</noscript>
|
||||||
<?php
|
<?php
|
||||||
if ($result->prerequisites) {
|
if ($result->prerequisites) {
|
||||||
if ($scorm->popup != 0) {
|
if ($scorm->popup != 0 && $displaymode !=='popup') {
|
||||||
// Clean the name for the window as IE is fussy
|
// Clean the name for the window as IE is fussy
|
||||||
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
|
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
|
@ -235,8 +233,9 @@ if ($result->prerequisites) {
|
||||||
}
|
}
|
||||||
$name = 'scorm_'.$name;
|
$name = 'scorm_'.$name;
|
||||||
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
|
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
|
||||||
|
$url = new moodle_url($PAGE->url, array('scoid' => $sco->id, 'display' => 'popup'));
|
||||||
echo html_writer::script(
|
echo html_writer::script(
|
||||||
js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop,
|
js_writer::function_call('scorm_openpopup', Array($url->out(false),
|
||||||
$name, $scorm->options,
|
$name, $scorm->options,
|
||||||
$scorm->width, $scorm->height)));
|
$scorm->width, $scorm->height)));
|
||||||
?>
|
?>
|
||||||
|
@ -257,12 +256,12 @@ if ($result->prerequisites) {
|
||||||
</div> <!-- SCORM page -->
|
</div> <!-- SCORM page -->
|
||||||
<?php
|
<?php
|
||||||
// NEW IMS TOC
|
// NEW IMS TOC
|
||||||
if (!isset($result->toctitle)) {
|
if (empty($scorm->popup) || $displaymode == 'popup') {
|
||||||
$result->toctitle = get_string('toc', 'scorm');
|
if (!isset($result->toctitle)) {
|
||||||
|
$result->toctitle = get_string('toc', 'scorm');
|
||||||
|
}
|
||||||
|
$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $sco->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $sco->id));
|
|
||||||
|
|
||||||
if (!empty($forcejs)) {
|
if (!empty($forcejs)) {
|
||||||
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
|
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#page-mod-scorm-view .structurelist {list-style-type: none;white-space: nowrap;}
|
#page-mod-scorm-view .structurelist {list-style-type: none;white-space: nowrap;}
|
||||||
#page-mod-scorm-view .structurelist {list-style-type: none;white-space: nowrap;}
|
#page-mod-scorm-view .structurelist {list-style-type: none;white-space: nowrap;}
|
||||||
|
|
||||||
#page-mod-scorm-player #altfinishlink {float: right; border: 0px; padding: 0px; }
|
#page-mod-scorm-player #altfinishlink {font-size: 140%;border: 0px; padding: 0px; }
|
||||||
#page-mod-scorm-player #altpopuplink {position: left; padding: 5px; border: 0px; }
|
#page-mod-scorm-player #altpopuplink {position: left; padding: 5px; border: 0px; }
|
||||||
#page-mod-scorm-player #scormmode {float: left; border: 0px; }
|
#page-mod-scorm-player #scormmode {float: left; border: 0px; }
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,6 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$module->version = 2011073100; // The (date) version of this module
|
$module->version = 2011080100; // The (date) version of this module
|
||||||
$module->requires = 2010080300; // The version of Moodle that is required
|
$module->requires = 2010080300; // The version of Moodle that is required
|
||||||
$module->cron = 300; // How often should cron check this module (seconds)?
|
$module->cron = 300; // How often should cron check this module (seconds)?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue