diff --git a/src/addons/mod/quiz/tests/behat/quiz_behaviour.feature b/src/addons/mod/quiz/tests/behat/quiz_behaviour.feature
new file mode 100644
index 000000000..adce06d9d
--- /dev/null
+++ b/src/addons/mod/quiz/tests/behat/quiz_behaviour.feature
@@ -0,0 +1,151 @@
+@mod @mod_quiz @app @javascript
+Feature: Use quizzes with different behaviours in the app
+
+ Background:
+ Given the following "courses" exist:
+ | fullname | shortname |
+ | Course 1 | C1 |
+ And the following "users" exist:
+ | username |
+ | student1 |
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | student1 | C1 | student |
+ And the following "question categories" exist:
+ | contextlevel | reference | name |
+ | Course | C1 | Test questions |
+ And the following "questions" exist:
+ | questioncategory | qtype | name |
+ | Test questions | multichoice | TF1 |
+
+ Scenario: Adaptive behaviour
+ Given the following "activities" exist:
+ | activity | name | course | idnumber | preferredbehaviour |
+ | quiz | Quiz | C1 | quiz | adaptive |
+ And quiz "Quiz" contains the following questions:
+ | question | page |
+ | TF1 | 1 |
+ And I entered the quiz activity "Quiz" on course "Course 1" as "student1" in the app
+ And I press "Attempt quiz now" in the app
+
+ When I press "Two" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "That is not right at all" in the app
+
+ When I press "Two" in the app
+ And I press "One" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Parts, but only parts, of your response are correct" in the app
+
+ When I press "Three" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Well done" in the app
+
+ When I press "Submit" in the app
+ And I press "Submit all and finish" in the app
+ And I press "OK" near "Once you submit" in the app
+ Then I should find "Mark 0.33 out of 1.00" in the app
+
+ Scenario: Immediate feedback behaviour
+ Given the following "activities" exist:
+ | activity | name | course | idnumber | preferredbehaviour | canredoquestions |
+ | quiz | Quiz | C1 | quiz | immediatefeedback | 1 |
+ And quiz "Quiz" contains the following questions:
+ | question | page |
+ | TF1 | 1 |
+ And I entered the quiz activity "Quiz" on course "Course 1" as "student1" in the app
+ And I press "Attempt quiz now" in the app
+
+ When I press "Two" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "That is not right at all" in the app
+ And I should find "Mark 0.00 out of 1.00" in the app
+
+ When I press "Try another question like this one" in the app
+ And I press "OK" near "Are you sure?" in the app
+ And I press "One" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Parts, but only parts, of your response are correct" in the app
+ And I should find "Mark 0.50 out of 1.00" in the app
+
+ When I press "Try another question like this one" in the app
+ And I press "OK" near "Are you sure?" in the app
+ And I press "One" in the app
+ And I press "Three" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Well done!" in the app
+ And I should find "The odd numbers are One and Three" in the app
+ And I should find "Mark 1.00 out of 1.00" in the app
+
+ When I press "Submit" in the app
+ And I press "Submit all and finish" in the app
+ And I press "OK" near "Once you submit" in the app
+ Then I should find "Mark 1.00 out of 1.00" in the app
+
+ Scenario: Deferred feedback with CBM behaviour
+ Given the following "activities" exist:
+ | activity | name | course | idnumber | preferredbehaviour |
+ | quiz | Quiz | C1 | quiz | deferredcbm |
+ And quiz "Quiz" contains the following questions:
+ | question | page |
+ | TF1 | 1 |
+ And I entered the quiz activity "Quiz" on course "Course 1" as "student1" in the app
+
+ When I press "Attempt quiz now" in the app
+ And I press "One" in the app
+ And I press "Four" in the app
+ And I press "Quite sure" in the app
+ And I press "Submit" in the app
+ And I press "Submit all and finish" in the app
+ And I press "OK" near "Once you submit" in the app
+ Then I should find "CBM mark 1.50" in the app
+ And I should find "Parts, but only parts, of your response are correct" in the app
+
+ Scenario: Interactive behaviour
+ Given the following "activities" exist:
+ | activity | name | course | idnumber | preferredbehaviour |
+ | quiz | Quiz | C1 | quiz | interactive |
+ And quiz "Quiz" contains the following questions:
+ | question | page |
+ | TF1 | 1 |
+ And I entered the quiz activity "Quiz" on course "Course 1" as "student1" in the app
+
+ When I press "Attempt quiz now" in the app
+ Then I should find "Tries remaining: 3" in the app
+
+ When I press "Two" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "That is not right at all" in the app
+ And I should find "Hint 1" in the app
+ And I should find "Tries remaining: 2" in the app
+
+ When I press "Try again" in the app
+ And I press "OK" near "Are you sure?" in the app
+ And I press "Two" in the app
+ And I press "One" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Parts, but only parts, of your response are correct" in the app
+ And I should find "Hint 2" in the app
+ And I should find "Tries remaining: 1" in the app
+
+ When I press "Try again" in the app
+ And I press "OK" near "Are you sure?" in the app
+ And I press "Three" in the app
+ And I press "Check" in the app
+ And I press "OK" near "Are you sure?" in the app
+ Then I should find "Well done!" in the app
+ And I should find "The odd numbers are One and Three" in the app
+ And I should find "Correct" within "Question 1" "ion-item-divider" in the app
+
+ When I press "Submit" in the app
+ And I press "Submit all and finish" in the app
+ And I press "OK" near "Once you submit" in the app
+ Then I should find "Mark 0.33 out of 1.00" in the app
diff --git a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature
index 63b0db1bf..c47e58dec 100644
--- a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature
+++ b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature
@@ -1,8 +1,5 @@
@mod @mod_quiz @app @javascript
-Feature: Attempt a quiz in app
- As a student
- In order to demonstrate what I know
- I need to be able to attempt quizzes
+Feature: Navigate through a quiz in the app
Background:
Given the following "courses" exist:
diff --git a/src/core/features/question/components/question/core-question.html b/src/core/features/question/components/question/core-question.html
index 994ba6a4d..2356fd868 100644
--- a/src/core/features/question/components/question/core-question.html
+++ b/src/core/features/question/components/question/core-question.html
@@ -21,7 +21,9 @@
- {{ button.value }}
+
+
diff --git a/src/core/features/question/services/question-helper.ts b/src/core/features/question/services/question-helper.ts
index 3777120f8..2880f5cd2 100644
--- a/src/core/features/question/services/question-helper.ts
+++ b/src/core/features/question/services/question-helper.ts
@@ -42,7 +42,7 @@ export class CoreQuestionHelperProvider {
* @param question Question.
* @param button Behaviour button (DOM element).
*/
- protected addBehaviourButton(question: CoreQuestionQuestion, button: HTMLInputElement): void {
+ protected addBehaviourButton(question: CoreQuestionQuestion, button: HTMLElement): void {
if (!button || !question) {
return;
}
@@ -50,10 +50,26 @@ export class CoreQuestionHelperProvider {
question.behaviourButtons = question.behaviourButtons || [];
// Extract the data we want.
+ if (button instanceof HTMLInputElement) {
+ // Old behaviour that changed in 4.2 because of MDL-78874.
+ question.behaviourButtons.push({
+ id: button.id,
+ name: button.name,
+ value: button.value,
+ disabled: button.disabled,
+ });
+
+ return;
+ }
+
+ if (!(button instanceof HTMLButtonElement)) {
+ return;
+ }
+
question.behaviourButtons.push({
id: button.id,
name: button.name,
- value: button.value,
+ value: button.innerHTML,
disabled: button.disabled,
});
}
@@ -101,7 +117,7 @@ export class CoreQuestionHelperProvider {
* The buttons aren't deleted from the content because all the im-controls block will be removed afterwards.
*
* @param question Question to treat.
- * @param selector Selector to search the buttons. By default, '.im-controls input[type="submit"]'.
+ * @param selector Selector to search the buttons. By default, '.im-controls [type="submit"]'.
*/
extractQbehaviourButtons(question: CoreQuestionQuestionParsed, selector?: string): void {
if (CoreQuestionDelegate.getPreventSubmitMessage(question)) {
@@ -109,7 +125,7 @@ export class CoreQuestionHelperProvider {
return;
}
- selector = selector || '.im-controls input[type="submit"]';
+ selector = selector || '.im-controls [type="submit"]';
const element = CoreDomUtils.convertToElement(question.html);
@@ -169,7 +185,7 @@ export class CoreQuestionHelperProvider {
*/
extractQbehaviourRedoButton(question: CoreQuestionQuestion): void {
// Create a fake div element so we can search using querySelector.
- const redoSelector = 'input[type="submit"][name*=redoslot], input[type="submit"][name*=tryagain]';
+ const redoSelector = '[type="submit"][name*=redoslot], [type="submit"][name*=tryagain]';
// Search redo button in feedback.
if (!this.searchBehaviourButton(question, 'html', '.outcome ' + redoSelector)) {
@@ -739,7 +755,7 @@ export class CoreQuestionHelperProvider {
protected searchBehaviourButton(question: CoreQuestionQuestion, htmlProperty: string, selector: string): boolean {
const element = CoreDomUtils.convertToElement(question[htmlProperty]);
- const button = element.querySelector(selector);
+ const button = element.querySelector(selector);
if (!button) {
return false;
}