From 0bcf7ad6b91d96cb7b6a0a1dc876df8dea9d9d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 16 Oct 2024 14:39:47 +0200 Subject: [PATCH] MOBILE-4616 course: Expand subsections of last viewed module --- .../components/course-format/course-format.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/features/course/components/course-format/course-format.ts b/src/core/features/course/components/course-format/course-format.ts index 91c0f7526..65ddf72f1 100644 --- a/src/core/features/course/components/course-format/course-format.ts +++ b/src/core/features/course/components/course-format/course-format.ts @@ -403,10 +403,23 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { this.viewedModules[entry.cmId] = true; }); - const lastViewedSection = this.getViewedModuleSection(); - if (lastViewedSection) { - this.setSectionExpanded(lastViewedSection); + if (!this.lastModuleViewed) { + return; } + + // Expand section and subsection of the last viewed module. + const { section, parents } = CoreCourseHelper.findSection(this.sections, { + id: this.lastModuleViewed.sectionId, + moduleId: this.lastModuleViewed.cmId, + }); + + if (section) { + parents.push(section); + } + parents.filter(section => section.id !== this.stealthModulesSectionId) + .forEach(section => { + this.setSectionExpanded(section); + }); } /**