diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index 515e08f709b..4736946ed26 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -85,14 +85,13 @@ echo $attemptobj->render_question_for_commenting($slot);
'; +$PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module()); // End of the page. echo $OUTPUT->footer(); diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 0e1ea245328..ae956d59f50 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -1294,12 +1294,14 @@ function quiz_check_safe_browser() { function quiz_get_js_module() { global $PAGE; + return array( 'name' => 'mod_quiz', 'fullpath' => '/mod/quiz/module.js', 'requires' => array('base', 'dom', 'event-delegate', 'event-key', 'core_question_engine'), 'strings' => array( + array('cancel', 'moodle'), array('timesup', 'quiz'), array('functiondisabledbysecuremode', 'quiz'), array('flagged', 'question'), diff --git a/mod/quiz/module.js b/mod/quiz/module.js index 7c11547ef85..457810b19b0 100644 --- a/mod/quiz/module.js +++ b/mod/quiz/module.js @@ -34,6 +34,14 @@ M.mod_quiz.init_review_form = function(Y) { Y.on('submit', function(e) { e.halt(); }, '.questionflagsaveform'); }; +M.mod_quiz.init_comment_popup = function(Y) { + // Add a close button to the window. + var closebutton = Y.Node.create(''); + closebutton.set('value', M.util.get_string('cancel', 'moodle')); + Y.one('#id_submitbutton').ancestor().append(closebutton); + Y.on('click', function() { window.close() }, closebutton); +} + // Code for updating the countdown timer that is used on timed quizzes. M.mod_quiz.timer = { // YUI object.