MDL-32729 Question: Correct button selection when openin qbank chooser

Some browsers do not bubble form submission events to the window, and we
had more than one form on the page in certain conditions. We need to select
all of the forms on a page and then test the action.
This commit is contained in:
Andrew Nicols 2014-04-02 09:41:31 +08:00
parent 0555761203
commit f87b22327f
5 changed files with 17 additions and 5 deletions

View File

@ -54,7 +54,7 @@ class behat_question_base extends behat_base {
return array(
new Given('I set the field "' . $this->escape($questiontypename) . '" to "1"'),
new Given('I click on "#chooseqtype_submit" "css_element"'),
new Given('I click on ".submitbutton" "css_element"'),
new Given('I set the following fields to these values:', $questiondata),
new Given('I press "id_submitbutton"')
);

View File

@ -14,7 +14,11 @@ function Chooser() {
Y.extend(Chooser, M.core.chooserdialogue, {
initializer: function() {
Y.one(SELECTORS.CREATENEWQUESTIONFORM).on('submit', this.displayQuestionChooser, this);
Y.all('form').each(function(node) {
if (/question\/addquestion\.php/.test(node.getAttribute('action'))) {
node.on('submit', this.displayQuestionChooser, this);
}
}, this);
},
displayQuestionChooser: function(e) {
var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE),

View File

@ -1 +1 @@
YUI.add("moodle-question-chooser",function(e,t){function r(){r.superclass.constructor.apply(this,arguments)}var n={CREATENEWQUESTION:"div.createnewquestion",CREATENEWQUESTIONFORM:"div.createnewquestion form",CHOOSERDIALOGUE:"div.chooserdialogue",CHOOSERHEADER:"div.choosertitle",QBANKCATEGORY:"#qbankcategory"};e.extend(r,M.core.chooserdialogue,{initializer:function(){e.one(n.CREATENEWQUESTIONFORM).on("submit",this.displayQuestionChooser,this)},displayQuestionChooser:function(t){var r=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERDIALOGUE),i=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERHEADER);this.container===null&&(this.setup_chooser_dialogue(r,i,{}),this.prepare_chooser()),this.container.one(n.QBANKCATEGORY).set("value",e.one(n.CREATENEWQUESTIONFORM).get("category").get("value")),this.display_chooser(t)}},{NAME:"questionChooser"}),M.question=M.question||{},M.question.init_chooser=function(e){return new r(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue"]});
YUI.add("moodle-question-chooser",function(e,t){function r(){r.superclass.constructor.apply(this,arguments)}var n={CREATENEWQUESTION:"div.createnewquestion",CREATENEWQUESTIONFORM:"div.createnewquestion form",CHOOSERDIALOGUE:"div.chooserdialogue",CHOOSERHEADER:"div.choosertitle",QBANKCATEGORY:"#qbankcategory"};e.extend(r,M.core.chooserdialogue,{initializer:function(){e.all("form").each(function(e){/question\/addquestion\.php/.test(e.getAttribute("action"))&&e.on("submit",this.displayQuestionChooser,this)},this)},displayQuestionChooser:function(t){var r=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERDIALOGUE),i=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERHEADER);this.container===null&&(this.setup_chooser_dialogue(r,i,{}),this.prepare_chooser()),this.container.one(n.QBANKCATEGORY).set("value",e.one(n.CREATENEWQUESTIONFORM).get("category").get("value")),this.display_chooser(t)}},{NAME:"questionChooser"}),M.question=M.question||{},M.question.init_chooser=function(e){return new r(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue"]});

View File

@ -14,7 +14,11 @@ function Chooser() {
Y.extend(Chooser, M.core.chooserdialogue, {
initializer: function() {
Y.one(SELECTORS.CREATENEWQUESTIONFORM).on('submit', this.displayQuestionChooser, this);
Y.all('form').each(function(node) {
if (/question\/addquestion\.php/.test(node.getAttribute('action'))) {
node.on('submit', this.displayQuestionChooser, this);
}
}, this);
},
displayQuestionChooser: function(e) {
var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE),

View File

@ -12,7 +12,11 @@ function Chooser() {
Y.extend(Chooser, M.core.chooserdialogue, {
initializer: function() {
Y.one(SELECTORS.CREATENEWQUESTIONFORM).on('submit', this.displayQuestionChooser, this);
Y.all('form').each(function(node) {
if (/question\/addquestion\.php/.test(node.getAttribute('action'))) {
node.on('submit', this.displayQuestionChooser, this);
}
}, this);
},
displayQuestionChooser: function(e) {
var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE),