MDL-43687 Javascript: Correct instantiation of the question-preview
This addresses issues discovered during testing, including: * inclusion of the M.core_question_preview metadata; * inclusion of required strings; and * correcting a function signature.
This commit is contained in:
@@ -275,6 +275,10 @@ print_collapsible_region_end();
|
||||
// Display the settings form.
|
||||
$optionsform->display();
|
||||
|
||||
$PAGE->requires->js_module('core_question_engine');
|
||||
$PAGE->requires->strings_for_js(array(
|
||||
'closepreview',
|
||||
), 'question');
|
||||
$PAGE->requires->yui_module('moodle-question-preview', 'M.question.preview.init');
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
+8
-4
@@ -24,18 +24,22 @@ YUI.add('moodle-question-preview', function (Y, NAME) {
|
||||
*/
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.preview = M.question.preview || {};
|
||||
|
||||
/**
|
||||
* Initialise JavaScript-specific parts of the question preview popup.
|
||||
*/
|
||||
M.question.preview.init = function(Y) {
|
||||
M.question.preview.init = function() {
|
||||
M.core_question_engine.init_form(Y, '#responseform');
|
||||
|
||||
// Add a close button to the window.
|
||||
var closebutton = Y.Node.create('<input type="button" />');
|
||||
closebutton.set('value', M.str.question.closepreview);
|
||||
var closebutton = Y.Node.create('<input type="button" />')
|
||||
.set('value', M.util.get_string('closepreview', 'question'));
|
||||
|
||||
closebutton.on('click', function() {
|
||||
window.close();
|
||||
});
|
||||
Y.one('#previewcontrols').append(closebutton);
|
||||
Y.on('click', function() { window.close(); }, closebutton);
|
||||
|
||||
// Stop a question form being submitted more than once.
|
||||
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
|
||||
|
||||
@@ -1 +1 @@
|
||||
YUI.add("moodle-question-preview",function(e,t){M.question=M.question||{},M.question.preview.init=function(e){M.core_question_engine.init_form(e,"#responseform");var t=e.Node.create('<input type="button" />');t.set("value",M.str.question.closepreview),e.one("#previewcontrols").append(t),e.on("click",function(){window.close()},t),e.on("submit",M.core_question_engine.prevent_repeat_submission,"#mform1",null,e)}},"@VERSION@",{requires:["base","dom","event-delegate","event-key","core_question_engine"]});
|
||||
YUI.add("moodle-question-preview",function(e,t){M.question=M.question||{},M.question.preview=M.question.preview||{},M.question.preview.init=function(){M.core_question_engine.init_form(e,"#responseform");var t=e.Node.create('<input type="button" />').set("value",M.util.get_string("closepreview","question"));t.on("click",function(){window.close()}),e.one("#previewcontrols").append(t),e.on("submit",M.core_question_engine.prevent_repeat_submission,"#mform1",null,e)}},"@VERSION@",{requires:["base","dom","event-delegate","event-key","core_question_engine"]});
|
||||
|
||||
@@ -24,18 +24,22 @@ YUI.add('moodle-question-preview', function (Y, NAME) {
|
||||
*/
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.preview = M.question.preview || {};
|
||||
|
||||
/**
|
||||
* Initialise JavaScript-specific parts of the question preview popup.
|
||||
*/
|
||||
M.question.preview.init = function(Y) {
|
||||
M.question.preview.init = function() {
|
||||
M.core_question_engine.init_form(Y, '#responseform');
|
||||
|
||||
// Add a close button to the window.
|
||||
var closebutton = Y.Node.create('<input type="button" />');
|
||||
closebutton.set('value', M.str.question.closepreview);
|
||||
var closebutton = Y.Node.create('<input type="button" />')
|
||||
.set('value', M.util.get_string('closepreview', 'question'));
|
||||
|
||||
closebutton.on('click', function() {
|
||||
window.close();
|
||||
});
|
||||
Y.one('#previewcontrols').append(closebutton);
|
||||
Y.on('click', function() { window.close(); }, closebutton);
|
||||
|
||||
// Stop a question form being submitted more than once.
|
||||
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
|
||||
|
||||
+8
-4
@@ -22,18 +22,22 @@
|
||||
*/
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.preview = M.question.preview || {};
|
||||
|
||||
/**
|
||||
* Initialise JavaScript-specific parts of the question preview popup.
|
||||
*/
|
||||
M.question.preview.init = function(Y) {
|
||||
M.question.preview.init = function() {
|
||||
M.core_question_engine.init_form(Y, '#responseform');
|
||||
|
||||
// Add a close button to the window.
|
||||
var closebutton = Y.Node.create('<input type="button" />');
|
||||
closebutton.set('value', M.str.question.closepreview);
|
||||
var closebutton = Y.Node.create('<input type="button" />')
|
||||
.set('value', M.util.get_string('closepreview', 'question'));
|
||||
|
||||
closebutton.on('click', function() {
|
||||
window.close();
|
||||
});
|
||||
Y.one('#previewcontrols').append(closebutton);
|
||||
Y.on('click', function() { window.close(); }, closebutton);
|
||||
|
||||
// Stop a question form being submitted more than once.
|
||||
Y.on('submit', M.core_question_engine.prevent_repeat_submission, '#mform1', null, Y);
|
||||
|
||||
Reference in New Issue
Block a user