MDL-81992 question bank: disable create question button until ready
Previously, you could click the button before it was ready, and that just led to an error, which was very silly usability.
This commit is contained in:
@@ -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([]);
|
||||
}
|
||||
|
||||
+7
-3
@@ -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);
|
||||
|
||||
+1
-1
@@ -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"]});
|
||||
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"]});
|
||||
+7
-3
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user