From 0efd23f019917743588867fb319482109bd09337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 28 Feb 2024 16:48:05 +0100 Subject: [PATCH] MOBILE-4498 completion: Decouple course completion services --- .../coursecompletion/coursecompletion.module.ts | 16 ++++++++++++---- src/core/features/compile/services/compile.ts | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/addons/coursecompletion/coursecompletion.module.ts b/src/addons/coursecompletion/coursecompletion.module.ts index 9ad8c137f..5dca1d450 100644 --- a/src/addons/coursecompletion/coursecompletion.module.ts +++ b/src/addons/coursecompletion/coursecompletion.module.ts @@ -19,14 +19,22 @@ import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.mo import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreUserDelegate } from '@features/user/services/user-delegate'; -import { AddonCourseCompletionProvider } from './services/coursecompletion'; import { AddonCourseCompletionStatusLinkHandler } from './services/handlers/completionstatus-link'; import { AddonCourseCompletionCourseOptionHandler } from './services/handlers/course-option'; import { AddonCourseCompletionUserHandler } from './services/handlers/user'; -export const ADDON_COURSECOMPLETION_SERVICES: Type[] = [ - AddonCourseCompletionProvider, -]; +/** + * Get course completion services. + * + * @returns Course completion services. + */ +export async function getCourseCompletionServices(): Promise[]> { + const { AddonCourseCompletionProvider } = await import('@addons/coursecompletion/services/coursecompletion'); + + return [ + AddonCourseCompletionProvider, + ]; +} const routes: Routes = [ { diff --git a/src/core/features/compile/services/compile.ts b/src/core/features/compile/services/compile.ts index f78ed4473..708cf9f01 100644 --- a/src/core/features/compile/services/compile.ts +++ b/src/core/features/compile/services/compile.ts @@ -126,7 +126,7 @@ import { CoreSitePluginsAssignSubmissionComponent } from '@features/siteplugins/ // Import addon providers. Do not import database module because it causes circular dependencies. import { ADDON_BADGES_SERVICES } from '@addons/badges/badges.module'; import { ADDON_CALENDAR_SERVICES } from '@addons/calendar/calendar.module'; -import { ADDON_COURSECOMPLETION_SERVICES } from '@addons/coursecompletion/coursecompletion.module'; +import { getCourseCompletionServices } from '@addons/coursecompletion/coursecompletion.module'; import { ADDON_COMPETENCY_SERVICES } from '@addons/competency/competency.module'; import { ADDON_MESSAGEOUTPUT_SERVICES } from '@addons/messageoutput/messageoutput.module'; import { ADDON_MESSAGES_SERVICES } from '@addons/messages/messages.module'; @@ -308,7 +308,6 @@ export class CoreCompileProvider { ...extraProviders, ...ADDON_BADGES_SERVICES, ...ADDON_CALENDAR_SERVICES, - ...ADDON_COURSECOMPLETION_SERVICES, ...ADDON_COMPETENCY_SERVICES, ...ADDON_MESSAGEOUTPUT_SERVICES, ...ADDON_MESSAGES_SERVICES, @@ -409,12 +408,14 @@ export class CoreCompileProvider { */ async getLazyLibraries(): Promise[]> { const ADDON_MOD_WORKSHOP_SERVICES = await getWorkshopServices(); + const ADDON_COURSECOMPLETION_SERVICES = await getCourseCompletionServices(); const CORE_COMMENTS_SERVICES = await getCommentsServices(); return [ ...ADDON_MOD_WORKSHOP_SERVICES, ...CORE_COMMENTS_SERVICES, + ...ADDON_COURSECOMPLETION_SERVICES, ]; }