--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Behat qtype_multichoice-related steps definitions.
+ *
+ * @package qtype_multichoice
+ * @category test
+ * @copyright 2020 Jun Pataleta
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Behat custom step definitions and partial named selectors for qtype_multichoice.
+ *
+ * @package qtype_multichoice
+ * @category test
+ * @copyright 2020 Jun Pataleta
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class behat_qtype_multichoice extends behat_base {
+
+ /**
+ * Return the list of partial named selectors for this plugin.
+ *
+ * @return behat_component_named_selector[]
+ */
+ public static function get_partial_named_selectors(): array {
+ return [
+ new behat_component_named_selector(
+ 'Answer', [
+ <<<XPATH
+ .//div[@data-region='answer-label']//*[contains(text(), %locator%)]
+XPATH
+ ]
+ ),
+ ];
+ }
+}
And I follow "Quiz 1"
And I press "Attempt quiz now"
And I should see "Question One"
- And I click on "Four" "radio" in the "Question One" "question"
+ And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question"
And I should see "Clear my choice"
And I click on "Clear my choice" "button" in the "Question One" "question"
Then I should not see "Clear my choice"
And I follow "Quiz 1"
And I press "Attempt quiz now"
And I should see "Question One"
- And I click on "Four" "radio" in the "Question One" "question"
+ And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question"
And I follow "Finish attempt ..."
And I click on "Return to attempt" "button"
And I click on "Clear my choice" "button" in the "Question One" "question"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
- And I click on "One" "checkbox"
- And I click on "Two" "checkbox"
+ And I click on "One" "qtype_multichoice > Answer"
+ And I click on "Two" "qtype_multichoice > Answer"
And I press "Check"
Then I should see "One is odd"
And I should see "Two is even"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
- And I click on "One" "checkbox"
- And I click on "Three" "checkbox"
+ And I click on "One" "qtype_multichoice > Answer"
+ And I click on "Three" "qtype_multichoice > Answer"
And I press "Check"
Then I should see "One is odd"
And I should see "Three is odd"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
- And I click on "One" "radio"
+ And I click on "One" "qtype_multichoice > Answer"
And I press "Check"
Then I should see "The oddest number is One."
And I should see "Mark 1.00 out of 1.00"
And I switch to "questionpreview" window
And I set the field "How questions behave" to "Immediate feedback"
And I press "Start again with these options"
- And I click on "One" "radio"
+ And I click on "One" "qtype_multichoice > Answer"
Then I should see "Clear my choice"
And I click on "Clear my choice" "text"
And I should not see "Clear my choice"
--- /dev/null
+This file describes API changes in /question/type/multichoice/*.
+
+=== 3.9.3 ===
+* The label for the multiple choice answers are being removed and the inputs (radio buttons/checkboxes) are now being labelled
+by the answer texts via the aria-labelledby attribute. Because of this, Behat steps that used to click on the labels for the
+multiple choice answer such as
+ And I click on "One" "checkbox"
+won't work anymore. This has been replaced by having Behat click on the answer text using the custom partial named selector
+"qtype_multichoice > Answer". So the above behat step would now be
+ And I click on "One" "qtype_multichoice > Answer"
+This applies to both single-answer and multiple-answer multiple choice question types.