Merge pull request #4035 from dpalou/MOBILE-4470

MOBILE-4470 course: Show all sections if last module is stealth
main
Noel De Martin 2024-05-07 09:07:14 +02:00 committed by GitHub
commit c2a16b66a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 9 deletions

View File

@ -382,18 +382,18 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
sections: CoreCourseSection[],
viewedModule: CoreCourseViewedModulesDBRecord,
): CoreCourseSection | undefined {
let lastModuleSection: CoreCourseSection | undefined;
if (viewedModule.sectionId) {
const lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
if (lastModuleSection) {
return lastModuleSection;
}
lastModuleSection = sections.find(section => section.id === viewedModule.sectionId);
}
if (!lastModuleSection) {
// No sectionId or section not found. Search the module.
return sections.find(
section => section.modules.some(module => module.id === viewedModule.cmId),
);
lastModuleSection = sections.find(section => section.modules.some(module => module.id === viewedModule.cmId));
}
return lastModuleSection && lastModuleSection.id !== this.stealthModulesSectionId ? lastModuleSection : undefined;
}
/**