mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-29975 SCORM improve pop-up generation
This commit is contained in:
parent
ead4f180a0
commit
d5159fb8d3
@ -785,7 +785,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
|
||||
?>
|
||||
<div class="scorm-center">
|
||||
<form id="theform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
|
||||
<form id="scormviewform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
|
||||
<?php
|
||||
if ($scorm->hidebrowse == 0) {
|
||||
print_string('mode', 'scorm');
|
||||
@ -805,6 +805,9 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
<label for="a"><?php print_string('newattempt', 'scorm') ?></label>
|
||||
<?php
|
||||
}
|
||||
if (!empty($scorm->popup)) {
|
||||
echo '<input type="hidden" name="display" value="popup" />'."\n";
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
<input type="hidden" name="scoid"/>
|
||||
|
19
mod/scorm/view.js
Normal file
19
mod/scorm/view.js
Normal file
@ -0,0 +1,19 @@
|
||||
M.mod_scormform = {};
|
||||
M.mod_scormform.init = function(Y) {
|
||||
var scormform = Y.one('#scormviewform');
|
||||
var cwidth = scormplayerdata.cwidth;
|
||||
var cheight = scormplayerdata.cheight;
|
||||
var poptions = scormplayerdata.popupoptions;
|
||||
if ((cwidth==100) && (cheight==100)) {
|
||||
poptions = poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0';
|
||||
} else {
|
||||
if (cwidth<=100) {
|
||||
cwidth = Math.round(screen.availWidth * cwidth / 100);
|
||||
}
|
||||
if (cheight<=100) {
|
||||
cheight = Math.round(screen.availHeight * cheight / 100);
|
||||
}
|
||||
poptions = poptions+',width='+cwidth+',height='+cheight;
|
||||
}
|
||||
scormform.setAttribute('onsubmit', "window.open('','Popup','"+poptions+"'); this.target='Popup';");
|
||||
}
|
@ -58,6 +58,13 @@ if (!empty($forcejs)) {
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
if (!empty($scorm->popup)) {
|
||||
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
|
||||
'cheight'=>$scorm->height,
|
||||
'popupoptions' => $scorm->options), true);
|
||||
$PAGE->requires->js('/mod/scorm/view.js', true);
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
@ -125,4 +132,9 @@ if ($scormopen) {
|
||||
if (!empty($forcejs)) {
|
||||
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
|
||||
}
|
||||
|
||||
if (!empty($scorm->popup)) {
|
||||
$PAGE->requires->js_init_call('M.mod_scormform.init');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user