MOBILE-4428 quiz: Fix adaptive behaviour
parent
2019283bd1
commit
3183737463
|
@ -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
|
|
@ -1,8 +1,5 @@
|
||||||
@mod @mod_quiz @app @javascript
|
@mod @mod_quiz @app @javascript
|
||||||
Feature: Attempt a quiz in app
|
Feature: Navigate through a quiz in the app
|
||||||
As a student
|
|
||||||
In order to demonstrate what I know
|
|
||||||
I need to be able to attempt quizzes
|
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the following "courses" exist:
|
Given the following "courses" exist:
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
<!-- Question behaviour buttons. -->
|
<!-- Question behaviour buttons. -->
|
||||||
<ion-button *ngFor="let button of question?.behaviourButtons" class="ion-margin-vertical ion-text-wrap" expand="block"
|
<ion-button *ngFor="let button of question?.behaviourButtons" class="ion-margin-vertical ion-text-wrap" expand="block"
|
||||||
(click)="buttonClicked.emit(button)" [disabled]="button.disabled">
|
(click)="buttonClicked.emit(button)" [disabled]="button.disabled">
|
||||||
{{ button.value }}
|
<core-format-text [component]="component" [componentId]="componentId" [text]="button.value" [contextLevel]="contextLevel"
|
||||||
|
[contextInstanceId]="contextInstanceId" [courseId]="courseId">
|
||||||
|
</core-format-text>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
|
|
||||||
<!-- Question feedback. -->
|
<!-- Question feedback. -->
|
||||||
|
|
|
@ -42,7 +42,7 @@ export class CoreQuestionHelperProvider {
|
||||||
* @param question Question.
|
* @param question Question.
|
||||||
* @param button Behaviour button (DOM element).
|
* @param button Behaviour button (DOM element).
|
||||||
*/
|
*/
|
||||||
protected addBehaviourButton(question: CoreQuestionQuestion, button: HTMLInputElement): void {
|
protected addBehaviourButton(question: CoreQuestionQuestion, button: HTMLElement): void {
|
||||||
if (!button || !question) {
|
if (!button || !question) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,26 @@ export class CoreQuestionHelperProvider {
|
||||||
question.behaviourButtons = question.behaviourButtons || [];
|
question.behaviourButtons = question.behaviourButtons || [];
|
||||||
|
|
||||||
// Extract the data we want.
|
// 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({
|
question.behaviourButtons.push({
|
||||||
id: button.id,
|
id: button.id,
|
||||||
name: button.name,
|
name: button.name,
|
||||||
value: button.value,
|
value: button.innerHTML,
|
||||||
disabled: button.disabled,
|
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.
|
* The buttons aren't deleted from the content because all the im-controls block will be removed afterwards.
|
||||||
*
|
*
|
||||||
* @param question Question to treat.
|
* @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 {
|
extractQbehaviourButtons(question: CoreQuestionQuestionParsed, selector?: string): void {
|
||||||
if (CoreQuestionDelegate.getPreventSubmitMessage(question)) {
|
if (CoreQuestionDelegate.getPreventSubmitMessage(question)) {
|
||||||
|
@ -109,7 +125,7 @@ export class CoreQuestionHelperProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selector = selector || '.im-controls input[type="submit"]';
|
selector = selector || '.im-controls [type="submit"]';
|
||||||
|
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = CoreDomUtils.convertToElement(question.html);
|
||||||
|
|
||||||
|
@ -169,7 +185,7 @@ export class CoreQuestionHelperProvider {
|
||||||
*/
|
*/
|
||||||
extractQbehaviourRedoButton(question: CoreQuestionQuestion): void {
|
extractQbehaviourRedoButton(question: CoreQuestionQuestion): void {
|
||||||
// Create a fake div element so we can search using querySelector.
|
// 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.
|
// Search redo button in feedback.
|
||||||
if (!this.searchBehaviourButton(question, 'html', '.outcome ' + redoSelector)) {
|
if (!this.searchBehaviourButton(question, 'html', '.outcome ' + redoSelector)) {
|
||||||
|
@ -739,7 +755,7 @@ export class CoreQuestionHelperProvider {
|
||||||
protected searchBehaviourButton(question: CoreQuestionQuestion, htmlProperty: string, selector: string): boolean {
|
protected searchBehaviourButton(question: CoreQuestionQuestion, htmlProperty: string, selector: string): boolean {
|
||||||
const element = CoreDomUtils.convertToElement(question[htmlProperty]);
|
const element = CoreDomUtils.convertToElement(question[htmlProperty]);
|
||||||
|
|
||||||
const button = <HTMLInputElement> element.querySelector(selector);
|
const button = element.querySelector<HTMLElement>(selector);
|
||||||
if (!button) {
|
if (!button) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue