Skip to content

Commit 5adad7f

Browse files
MOBILE-4132 Book: Fix single activity navigation
1 parent 138377e commit 5adad7f

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

src/addons/mod/book/components/index/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { AddonModBook, AddonModBookBookWSData, AddonModBookNumbering, AddonModBo
1818
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
1919
import { CoreCourse } from '@features/course/services/course';
2020
import { CoreNavigator } from '@services/navigator';
21+
import { AddonModBookModuleHandlerService } from '../../services/handlers/module';
2122

2223
/**
2324
* Component that displays a book entry page.
@@ -109,14 +110,11 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
109110
*
110111
* @param chapterId Chapter to open, undefined for last chapter viewed.
111112
*/
112-
openBook(chapterId?: number): void {
113-
CoreNavigator.navigate('contents', {
114-
params: {
115-
cmId: this.module.id,
116-
courseId: this.courseId,
117-
chapterId,
118-
},
119-
});
113+
async openBook(chapterId?: number): Promise<void> {
114+
await CoreNavigator.navigateToSitePath(
115+
`${AddonModBookModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/contents`,
116+
{ params: { chapterId } },
117+
);
120118

121119
this.hasStartedBook = true;
122120
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@app @javascript @mod @mod_book
2+
Feature: Test single activity of book type in app
3+
In order to view a book while using the mobile app
4+
As a student
5+
I need single activity of book type functionality to work
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname |
10+
| student1 | First | Student |
11+
And the following "courses" exist:
12+
| fullname | shortname | category | format | activitytype |
13+
| Course 1 | C1 | 0 | singleactivity | book |
14+
And the following "course enrolments" exist:
15+
| user | course | role |
16+
| student1 | C1 | student |
17+
And the following "activity" exist:
18+
| activity | name | intro | course | idnumber | numbering | section |
19+
| book | Single activity book | Test book description | C1 | 1 | 1 | 0 |
20+
And the following "mod_book > chapter" exist:
21+
| book | title | content | subchapter | hidden | pagenum |
22+
| Single activity book | Chapt 1 | This is the first chapter | 0 | 0 | 1 |
23+
| Single activity book | Chapt 2 | This is the second chapter | 0 | 0 | 1 |
24+
| Single activity book | Chapt 3 | This is the third chapter | 0 | 0 | 1 |
25+
26+
Scenario: Single activity book
27+
Given I entered the course "Course 1" as "student1" in the app
28+
Then I should find "Chapt 1" in the app
29+
And I should find "Chapt 2" in the app
30+
And I press "Chapt 1" in the app
31+
Then I should find "Chapt 1" in the app
32+
And I should find "This is the first chapter" in the app
33+
But I should not find "This is the second chapter" in the app

0 commit comments

Comments
 (0)