Skip to content

Commit 594408b

Browse files
authored
Merge pull request #4402 from crazyserver/MOBILE-4653
MOBILE-4653 page: Test course completion on pages
2 parents a8c916a + c0835b1 commit 594408b

File tree

5 files changed

+231
-40
lines changed

5 files changed

+231
-40
lines changed

src/addons/mod/page/tests/behat/basic_usage.feature

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ Feature: Test basic usage of page activity in app
1818
Scenario: View contents
1919
Given I entered the course "Course 1" as "student1" in the app
2020
When I press "Test page title" in the app
21-
Then I should find "Test page content" in the app
21+
Then the header should be "Test page title" in the app
22+
And I should find "Test page content" in the app
2223
And the following events should have been logged for "student1" in the app:
2324
| name | activity | activityname | course |
2425
| \mod_page\event\course_module_viewed | page | Test page title | Course 1 |
26+
27+
Scenario: Prefecth page
28+
Given I entered the course "Course 1" as "student1" in the app
29+
When I press "Course downloads" in the app
30+
And I press "Download" within "Test page title" "ion-item" in the app
31+
Then I should find "Downloaded" within "Test page title" "ion-item" in the app
32+
When I switch network connection to offline
33+
And I go back in the app
34+
Then I should find "Downloaded" within "Test page title" "ion-card" in the app
35+
When I press "Test page title" in the app
36+
Then the header should be "Test page title" in the app
37+
And I should find "Test page content" in the app
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
@addon_mod_page @app @mod @mod_page @javascript @core_completion
2+
Feature: View activity completion information in the Page resource
3+
In order to have visibility of page completion requirements
4+
As a student
5+
I need to be able to view my page completion progress
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| student1 | Vinnie | Student1 | student1@example.com |
11+
| teacher1 | Darrell | Teacher1 | teacher1@example.com |
12+
And the following "courses" exist:
13+
| fullname | shortname | category | enablecompletion | showcompletionconditions |
14+
| Course 1 | C1 | 0 | 1 | 1 |
15+
| Course 2 | C2 | 0 | 1 | 0 |
16+
And the following "course enrolments" exist:
17+
| user | course | role |
18+
| student1 | C1 | student |
19+
| student1 | C2 | student |
20+
| teacher1 | C1 | editingteacher |
21+
| teacher1 | C2 | editingteacher |
22+
23+
Scenario: A teacher can view a page resource automatic completion items
24+
Given the following "activity" exists:
25+
| activity | page |
26+
| course | C1 |
27+
| idnumber | page1 |
28+
| name | Music history |
29+
| intro | A lesson learned in life |
30+
| completion | 2 |
31+
| completionview | 1 |
32+
When I entered the course "Course 1" as "teacher1" in the app
33+
And I press "Completion" within "Music history" "ion-card" in the app
34+
Then I should not find "To do:" in the app
35+
And I should find "View" in the app
36+
When I close the popup in the app
37+
And I press "Music history" in the app
38+
Then the header should be "Music history" in the app
39+
When I press "Completion" in the app
40+
Then I should not find "To do:" in the app
41+
And I should find "View" in the app
42+
43+
Scenario: A student can complete a page resource by viewing it
44+
Given the following "activity" exists:
45+
| activity | page |
46+
| course | C1 |
47+
| idnumber | page1 |
48+
| name | Music history |
49+
| intro | A lesson learned in life |
50+
| completion | 2 |
51+
| completionview | 1 |
52+
When I entered the course "Course 1" as "student1" in the app
53+
And I press "To do" within "Music history" "ion-card" in the app
54+
Then I should find "To do:" in the app
55+
And I should find "View" in the app
56+
When I close the popup in the app
57+
And I press "Music history" in the app
58+
Then the header should be "Music history" in the app
59+
When I press "Done" in the app
60+
Then I should find "Done:" in the app
61+
And I should find "View" in the app
62+
When I close the popup in the app
63+
And I go back in the app
64+
And I press "Done" within "Music history" "ion-card" in the app
65+
Then I should find "Done:" in the app
66+
And I should find "View" in the app
67+
68+
Scenario: A teacher cannot manually mark the page activity as done
69+
Given the following "activity" exists:
70+
| activity | page |
71+
| course | C1 |
72+
| idnumber | page1 |
73+
| name | Music history |
74+
| intro | A lesson learned in life |
75+
| completion | 1 |
76+
When I entered the course "Course 1" as "teacher1" in the app
77+
Then I should find "Mark as done" in the app
78+
When I press "Music history" in the app
79+
Then the header should be "Music history" in the app
80+
And I should find "Mark as done" in the app
81+
But I should not be able to press "Mark as done" in the app
82+
83+
Scenario: A student can manually mark the page activity as done
84+
Given the following "activity" exists:
85+
| activity | page |
86+
| course | C1 |
87+
| idnumber | page1 |
88+
| name | Music history |
89+
| intro | A lesson learned in life |
90+
| completion | 1 |
91+
When I entered the course "Course 1" as "student1" in the app
92+
And I press "Mark as done" within "Music history" "ion-card" in the app
93+
Then I should find "Done" in the app
94+
When I press "Done" within "Music history" "ion-card" in the app
95+
Then I should find "Mark as done" in the app
96+
When I press "Music history" in the app
97+
Then the header should be "Music history" in the app
98+
When I press "Mark as done" in the app
99+
Then I should find "Done" in the app
100+
When I press "Done" in the app
101+
Then I should find "Mark as done" in the app
102+
103+
Scenario: The manual completion button will not be shown on the course page if the Show activity completion conditions is set to No as teacher
104+
Given the following "activity" exists:
105+
| activity | page |
106+
| course | C2 |
107+
| idnumber | page1 |
108+
| name | Music history |
109+
| intro | A lesson learned in life |
110+
| completion | 1 |
111+
When I entered the course "Course 2" as "teacher1" in the app
112+
Then I should not find "Mark as done" in the app
113+
When I press "Music history" in the app
114+
Then the header should be "Music history" in the app
115+
And I should find "Mark as done" in the app
116+
117+
Scenario: The manual completion button will not be shown on the course page if the Show activity completion conditions is set to No as student
118+
Given the following "activity" exists:
119+
| activity | page |
120+
| course | C2 |
121+
| idnumber | page1 |
122+
| name | Music history |
123+
| intro | A lesson learned in life |
124+
| completion | 1 |
125+
When I entered the course "Course 2" as "student1" in the app
126+
Then I should not find "Mark as done" in the app
127+
When I press "Music history" in the app
128+
Then the header should be "Music history" in the app
129+
And I should find "Mark as done" in the app
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@addon_mod_page @app @mod @mod_page @javascript
2+
Feature: Configure page appearance
3+
In order to change the appearance of the page resource
4+
As an admin
5+
I need to configure the page appearance settings
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| student1 | Student | student | student1@example.com |
11+
And the following "courses" exist:
12+
| fullname | shortname | category |
13+
| Course 1 | C1 | 0 |
14+
And the following "course enrolments" exist:
15+
| user | course | role |
16+
| student1 | C1 | student |
17+
And the following "activities" exist:
18+
| activity | name | intro | course | idnumber |
19+
| page | PageName1 | PageDesc1 | C1 | PAGE1 |
20+
21+
Scenario Outline: Hide and display page features
22+
Given I am on the "PageName1" "page activity editing" page logged in as admin
23+
And I expand all fieldsets
24+
And I set the field "<feature>" to "<value>"
25+
And I press "Save and display"
26+
And I entered the course "Course 1" as "student1" in the app
27+
When I press "PageName1" in the app
28+
Then I <shouldornot> find "<lookfor>" in the app
29+
30+
Examples:
31+
| feature | lookfor | value | shouldornot |
32+
| Display page description | PageDesc1 | 1 | should |
33+
| Display page description | PageDesc1 | 0 | should not |
34+
| Display last modified date | Last modified: | 1 | should |
35+
| Display last modified date | Last modified: | 0 | should not |
Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
1-
<ng-container *ngIf="showCompletionInfo && completion">
2-
<ng-container *ngIf="completion.istrackeduser">
3-
<ng-container *ngIf="completion.isautomatic">
4-
<ion-button class="completioninfo completion_incomplete chip ion-text-nowrap" *ngIf="!completed" fill="outline"
5-
(click)="completionClicked($event)">
6-
{{ 'core.course.todo' | translate }}
1+
@if (showCompletionInfo && completion) {
2+
@if (completion.istrackeduser) {
3+
@if (completion.isautomatic) {
4+
@if (!completed) {
5+
<ion-button class="completioninfo completion_incomplete chip ion-text-nowrap" fill="outline"
6+
(click)="completionClicked($event)">
7+
{{ 'core.course.todo' | translate }}
8+
<div class="select-icon" role="presentation" aria-hidden="true">
9+
<div class="select-icon-inner"></div>
10+
</div>
11+
</ion-button>
12+
} @else {
13+
<ion-button class="completioninfo completion_complete chip ion-text-nowrap" color="success"
14+
(click)="completionClicked($event)">
15+
<ion-icon name="fas-check" slot="start" aria-hidden="true" />
16+
{{'core.course.done' | translate }}
17+
<div class="select-icon" role="presentation" aria-hidden="true">
18+
<div class="select-icon-inner"></div>
19+
</div>
20+
</ion-button>
21+
}
22+
} @else {
23+
@if (completed) {
24+
<ion-button color="success" [ariaLabel]="accessibleDescription" (click)="completionClicked($event)"
25+
class="completioninfo completion_complete chip ion-text-nowrap">
26+
<ion-icon name="fas-check" slot="start" aria-hidden="true" />
27+
{{ 'core.course.completion_manual:done' | translate }}
28+
@if (completion.offline) {
29+
<ion-icon name="fas-arrows-rotate" [attr.aria-label]="'core.course.manualcompletionnotsynced' | translate"
30+
slot="end" />
31+
}
32+
</ion-button>
33+
} @else {
34+
<ion-button fill="outline" [ariaLabel]="accessibleDescription" (click)="completionClicked($event)"
35+
class="completioninfo completion_incomplete chip ion-text-nowrap">
36+
{{ 'core.course.completion_manual:markdone' | translate }}
37+
@if (completion.offline) {
38+
<ion-icon name="fas-arrows-rotate" [attr.aria-label]="'core.course.manualcompletionnotsynced' | translate"
39+
slot="end" />
40+
}
41+
</ion-button>
42+
}
43+
}
44+
} @else {
45+
@if (completion.isautomatic) {
46+
<ion-button fill="outline" class="chip ion-text-nowrap" (click)="completionClicked($event)">
47+
{{ 'core.course.completionmenuitem' | translate }}
748
<div class="select-icon" role="presentation" aria-hidden="true">
849
<div class="select-icon-inner"></div>
950
</div>
1051
</ion-button>
11-
12-
<ion-button class="completioninfo completion_complete chip ion-text-nowrap" color="success" (click)="completionClicked($event)"
13-
*ngIf="completed">
14-
<ion-icon name="fas-check" slot="start" aria-hidden="true" />
15-
{{'core.course.done' | translate }}
16-
<div class="select-icon" role="presentation" aria-hidden="true">
17-
<div class="select-icon-inner"></div>
18-
</div>
19-
</ion-button>
20-
</ng-container>
21-
22-
<ng-container *ngIf="!completion.isautomatic">
23-
<ion-button *ngIf="completed" color="success" [ariaLabel]="accessibleDescription" (click)="completionClicked($event)"
24-
class="completioninfo completion_complete chip ion-text-nowrap">
25-
<ion-icon name="fas-check" slot="start" aria-hidden="true" />
26-
{{ 'core.course.completion_manual:done' | translate }}
27-
<ion-icon *ngIf="completion.offline" name="fas-arrows-rotate"
28-
[attr.aria-label]="'core.course.manualcompletionnotsynced' | translate" slot="end" />
29-
</ion-button>
30-
<ion-button *ngIf="!completed" fill="outline" [ariaLabel]="accessibleDescription" (click)="completionClicked($event)"
52+
} @else {
53+
<ion-button fill="outline" [ariaLabel]="accessibleDescription" disabled
3154
class="completioninfo completion_incomplete chip ion-text-nowrap">
3255
{{ 'core.course.completion_manual:markdone' | translate }}
33-
<ion-icon *ngIf="completion.offline" name="fas-arrows-rotate"
34-
[attr.aria-label]="'core.course.manualcompletionnotsynced' | translate" slot="end" />
3556
</ion-button>
36-
</ng-container>
37-
</ng-container>
38-
39-
<ion-button *ngIf="!completion.istrackeduser" fill="outline" class="chip ion-text-nowrap" (click)="completionClicked($event)">
40-
{{ 'core.course.completionmenuitem' | translate }}
41-
<div class="select-icon" role="presentation" aria-hidden="true">
42-
<div class="select-icon-inner"></div>
43-
</div>
44-
</ion-button>
45-
</ng-container>
57+
}
58+
}
59+
}

src/core/singletons/iframe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class CoreIframe {
136136

137137
if (!canHandleLink) {
138138
div.innerHTML = (isSubframe ? '' : '<div class="core-iframe-network-error"></div>') +
139-
`<p>${Translate.instant('core.networkerroriframemsg')}</p>`;
139+
`<p>${Translate.instant('core.notavailableoffline')}</p>`;
140140

141141
element.parentElement?.insertBefore(div, element);
142142

0 commit comments

Comments
 (0)