MDL-73662 mod_quiz: fix initialization arguments to close button.

Co-authored-by: Sergio Rabellino <rabellino@di.unito.it>
This commit is contained in:
Paul Holden 2024-07-11 21:09:08 +01:00
parent fd487cd3f2
commit 7d030bba77
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
2 changed files with 16 additions and 3 deletions

View File

@ -705,7 +705,7 @@ class renderer extends plugin_renderer_base {
$delay = 0;
}
$this->page->requires->js_init_call('M.mod_quiz.secure_window.close',
[$url, $delay], false, quiz_get_js_module());
[$url->out(false), $delay], false, quiz_get_js_module());
$output .= $this->box_end();
$output .= $this->footer();

View File

@ -398,13 +398,26 @@ M.mod_quiz.secure_window = {
e.halt();
},
/**
* Initialize the event listener for the secure window close button
*
* @param {Object} Y YUI instance. When called from renderer, this parameter precedes the others
* @param {String} url
*/
init_close_button: function(Y, url) {
Y.on('click', function(e) {
M.mod_quiz.secure_window.close(url, 0)
M.mod_quiz.secure_window.close(Y, url, 0);
}, '#secureclosebutton');
},
close: function(url, delay) {
/**
* Close the secure window, or redirect to URL if the opener is no longer present
*
* @param {Object} Y YUI instance. When called from renderer, this parameter precedes the others
* @param {String} url
* @param {Number} delay
*/
close: function(Y, url, delay) {
setTimeout(function() {
if (window.opener) {
window.opener.document.location.reload();