Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-29975 SCORM improve pop-up generation

  • Loading branch information...
commit d5159fb8d31985eb98025175ee7d708d1e42446c 1 parent ead4f18
Dan Marsden danmarsden authored
5 mod/scorm/locallib.php
@@ -785,7 +785,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
785 785 if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
786 786 ?>
787 787 <div class="scorm-center">
788   - <form id="theform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
  788 + <form id="scormviewform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
789 789 <?php
790 790 if ($scorm->hidebrowse == 0) {
791 791 print_string('mode', 'scorm');
@@ -805,6 +805,9 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
805 805 <label for="a"><?php print_string('newattempt', 'scorm') ?></label>
806 806 <?php
807 807 }
  808 + if (!empty($scorm->popup)) {
  809 + echo '<input type="hidden" name="display" value="popup" />'."\n";
  810 + }
808 811 ?>
809 812 <br />
810 813 <input type="hidden" name="scoid"/>
19 mod/scorm/view.js
... ... @@ -0,0 +1,19 @@
  1 +M.mod_scormform = {};
  2 +M.mod_scormform.init = function(Y) {
  3 + var scormform = Y.one('#scormviewform');
  4 + var cwidth = scormplayerdata.cwidth;
  5 + var cheight = scormplayerdata.cheight;
  6 + var poptions = scormplayerdata.popupoptions;
  7 + if ((cwidth==100) && (cheight==100)) {
  8 + poptions = poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0';
  9 + } else {
  10 + if (cwidth<=100) {
  11 + cwidth = Math.round(screen.availWidth * cwidth / 100);
  12 + }
  13 + if (cheight<=100) {
  14 + cheight = Math.round(screen.availHeight * cheight / 100);
  15 + }
  16 + poptions = poptions+',width='+cwidth+',height='+cheight;
  17 + }
  18 + scormform.setAttribute('onsubmit', "window.open('','Popup','"+poptions+"'); this.target='Popup';");
  19 +}
12 mod/scorm/view.php
@@ -58,6 +58,13 @@
58 58
59 59 require_login($course->id, false, $cm);
60 60
  61 +if (!empty($scorm->popup)) {
  62 + $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
  63 + 'cheight'=>$scorm->height,
  64 + 'popupoptions' => $scorm->options), true);
  65 + $PAGE->requires->js('/mod/scorm/view.js', true);
  66 +}
  67 +
61 68 $context = get_context_instance(CONTEXT_COURSE, $course->id);
62 69 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
63 70
@@ -125,4 +132,9 @@
125 132 if (!empty($forcejs)) {
126 133 echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
127 134 }
  135 +
  136 +if (!empty($scorm->popup)) {
  137 + $PAGE->requires->js_init_call('M.mod_scormform.init');
  138 +}
  139 +
128 140 echo $OUTPUT->footer();

0 comments on commit d5159fb

Please sign in to comment.
Something went wrong with that request. Please try again.