diff --git a/question/bank/editquestion/classes/output/add_new_question.php b/question/bank/editquestion/classes/output/add_new_question.php index 60b97e8d9d3..242fe3c6e28 100644 --- a/question/bank/editquestion/classes/output/add_new_question.php +++ b/question/bank/editquestion/classes/output/add_new_question.php @@ -59,7 +59,8 @@ class add_new_question implements \renderable, \templatable { $addquestiondisplay['buttonhtml'] = $output->single_button( $url, get_string('createnewquestion', 'question'), - 'get' + 'get', + ['disabled' => 'disabled'], ); $addquestiondisplay['qtypeform'] = editquestion_helper::print_choose_qtype_to_add_form([]); } diff --git a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-debug.js b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-debug.js index f66e41aed8c..b5cf51899ef 100644 --- a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-debug.js +++ b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-debug.js @@ -34,12 +34,16 @@ function Chooser() { Y.extend(Chooser, M.core.chooserdialogue, { initializer: function() { - Y.all('form').each(function(node) { - if (/question\/bank\/editquestion\/addquestion\.php/.test(node.getAttribute('action'))) { - node.on('submit', this.displayQuestionChooser, this); + Y.all(SELECTORS.CREATENEWQUESTIONFORM).each(function(createForm) { + if (createForm.get('id') === 'chooserform') { + // Not the singlebutton form. Ignore. + return; } + createForm.on('submit', this.displayQuestionChooser, this); + createForm.one('button').set('disabled', false); }, this); }, + displayQuestionChooser: function(e) { var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE), header = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERHEADER); diff --git a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-min.js b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-min.js index e4b0ba1a8a7..3483059dd5d 100644 --- a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-min.js +++ b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser-min.js @@ -1 +1 @@ -YUI.add("moodle-qbank_editquestion-chooser",function(n,e){var s="div.createnewquestion",r="div.chooserdialoguebody",u="div.choosertitle";function o(){o.superclass.constructor.apply(this,arguments)}n.extend(o,M.core.chooserdialogue,{initializer:function(){n.all("form").each(function(e){/question\/bank\/editquestion\/addquestion\.php/.test(e.getAttribute("action"))&&e.on("submit",this.displayQuestionChooser,this)},this)},displayQuestionChooser:function(e){var o,i=n.one(s+" "+r),t=n.one(s+" "+u);null===this.container&&(this.setup_chooser_dialogue(i,t,{}),this.prepare_chooser()),i=e.target.ancestor("form",!0),o=this.container.one("form"),t=i.all('input[type="hidden"]'),o.all("input.customfield").remove(),t.each(function(e){o.appendChild(e.cloneNode()).removeAttribute("id").addClass("customfield")}),this.display_chooser(e)}},{NAME:"questionChooser"}),M.question=M.question||{},M.question.init_chooser=function(e){return new o(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue"]}); \ No newline at end of file +YUI.add("moodle-qbank_editquestion-chooser",function(n,e){var s="div.createnewquestion",o="div.createnewquestion form",r="div.chooserdialoguebody",u="div.choosertitle";function i(){i.superclass.constructor.apply(this,arguments)}n.extend(i,M.core.chooserdialogue,{initializer:function(){n.all(o).each(function(e){"chooserform"!==e.get("id")&&(e.on("submit",this.displayQuestionChooser,this),e.one("button").set("disabled",!1))},this)},displayQuestionChooser:function(e){var o,i=n.one(s+" "+r),t=n.one(s+" "+u);null===this.container&&(this.setup_chooser_dialogue(i,t,{}),this.prepare_chooser()),i=e.target.ancestor("form",!0),o=this.container.one("form"),t=i.all('input[type="hidden"]'),o.all("input.customfield").remove(),t.each(function(e){o.appendChild(e.cloneNode()).removeAttribute("id").addClass("customfield")}),this.display_chooser(e)}},{NAME:"questionChooser"}),M.question=M.question||{},M.question.init_chooser=function(e){return new i(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue"]}); \ No newline at end of file diff --git a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser.js b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser.js index f66e41aed8c..b5cf51899ef 100644 --- a/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser.js +++ b/question/bank/editquestion/yui/build/moodle-qbank_editquestion-chooser/moodle-qbank_editquestion-chooser.js @@ -34,12 +34,16 @@ function Chooser() { Y.extend(Chooser, M.core.chooserdialogue, { initializer: function() { - Y.all('form').each(function(node) { - if (/question\/bank\/editquestion\/addquestion\.php/.test(node.getAttribute('action'))) { - node.on('submit', this.displayQuestionChooser, this); + Y.all(SELECTORS.CREATENEWQUESTIONFORM).each(function(createForm) { + if (createForm.get('id') === 'chooserform') { + // Not the singlebutton form. Ignore. + return; } + createForm.on('submit', this.displayQuestionChooser, this); + createForm.one('button').set('disabled', false); }, this); }, + displayQuestionChooser: function(e) { var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE), header = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERHEADER); diff --git a/question/bank/editquestion/yui/src/chooser/js/chooser.js b/question/bank/editquestion/yui/src/chooser/js/chooser.js index 9b4c03b75e0..dee9c5c8292 100644 --- a/question/bank/editquestion/yui/src/chooser/js/chooser.js +++ b/question/bank/editquestion/yui/src/chooser/js/chooser.js @@ -32,12 +32,16 @@ function Chooser() { Y.extend(Chooser, M.core.chooserdialogue, { initializer: function() { - Y.all('form').each(function(node) { - if (/question\/bank\/editquestion\/addquestion\.php/.test(node.getAttribute('action'))) { - node.on('submit', this.displayQuestionChooser, this); + Y.all(SELECTORS.CREATENEWQUESTIONFORM).each(function(createForm) { + if (createForm.get('id') === 'chooserform') { + // Not the singlebutton form. Ignore. + return; } + createForm.on('submit', this.displayQuestionChooser, this); + createForm.one('button').set('disabled', false); }, this); }, + displayQuestionChooser: function(e) { var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE), header = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERHEADER);