From 1d469cae30ed32702da672d64bb5d192c7bfe5d8 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 14 Sep 2011 20:25:31 +0100 Subject: [PATCH] MDL-29360 quiz comment.php has broken JS for the Cancel button. This swtichest it to more modern YUI3 approach. --- mod/quiz/comment.php | 5 +++-- mod/quiz/locallib.php | 2 ++ mod/quiz/module.js | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index ea8da3a8454..f22dbce9923 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -74,14 +74,15 @@
- - +
'; + $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 83f19c24257..fec8fa9c3a4 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -1239,11 +1239,13 @@ 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 6d3b4757a01..7768c949fc9 100644 --- a/mod/quiz/module.js +++ b/mod/quiz/module.js @@ -16,6 +16,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.