From f5d31d8eb4a43796715a0f90f7c1d48c3942bbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 29 Feb 2024 16:49:30 +0100 Subject: [PATCH] MOBILE-4497 competency: Decouple competency services --- src/addons/competency/competency.module.ts | 21 ++++++++++++------- src/core/features/compile/services/compile.ts | 5 +++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/addons/competency/competency.module.ts b/src/addons/competency/competency.module.ts index d705ed1c3..8cf0c600b 100644 --- a/src/addons/competency/competency.module.ts +++ b/src/addons/competency/competency.module.ts @@ -17,8 +17,6 @@ import { CoreContentLinksDelegate } from '@features/contentlinks/services/conten import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate'; import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; import { CoreUserDelegate } from '@features/user/services/user-delegate'; -import { AddonCompetencyProvider } from './services/competency'; -import { AddonCompetencyHelperProvider } from './services/competency-helper'; import { AddonCompetencyCompetencyLinkHandler } from './services/handlers/competency-link'; import { AddonCompetencyCourseOptionHandler } from './services/handlers/course-option'; import { AddonCompetencyPlanLinkHandler } from './services/handlers/plan-link'; @@ -33,11 +31,20 @@ import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.mo import { COURSE_PAGE_NAME } from '@features/course/course.module'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module'; -// List of providers (without handlers). -export const ADDON_COMPETENCY_SERVICES: Type[] = [ - AddonCompetencyProvider, - AddonCompetencyHelperProvider, -]; +/** + * Get competency services. + * + * @returns Competency services. + */ +export async function getCompetencyServices(): Promise[]> { + const { AddonCompetencyProvider } = await import('@addons/competency/services/competency'); + const { AddonCompetencyHelperProvider } = await import('@addons/competency/services/competency-helper'); + + return [ + AddonCompetencyProvider, + AddonCompetencyHelperProvider, + ]; +} export const ADDON_COMPETENCY_LEARNING_PLANS_PAGE = 'learning-plans'; export const ADDON_COMPETENCY_COMPETENCIES_PAGE = 'competencies'; diff --git a/src/core/features/compile/services/compile.ts b/src/core/features/compile/services/compile.ts index 77149f3a8..93ebfd090 100644 --- a/src/core/features/compile/services/compile.ts +++ b/src/core/features/compile/services/compile.ts @@ -127,7 +127,7 @@ import { CoreSitePluginsAssignSubmissionComponent } from '@features/siteplugins/ import { ADDON_BADGES_SERVICES } from '@addons/badges/badges.module'; import { ADDON_CALENDAR_SERVICES } from '@addons/calendar/calendar.module'; import { getCourseCompletionServices } from '@addons/coursecompletion/coursecompletion.module'; -import { ADDON_COMPETENCY_SERVICES } from '@addons/competency/competency.module'; +import { getCompetencyServices } from '@addons/competency/competency.module'; import { ADDON_MESSAGEOUTPUT_SERVICES } from '@addons/messageoutput/messageoutput.module'; import { ADDON_MESSAGES_SERVICES } from '@addons/messages/messages.module'; import { ADDON_MOD_ASSIGN_SERVICES } from '@addons/mod/assign/assign.module'; @@ -307,7 +307,6 @@ export class CoreCompileProvider { ...extraProviders, ...ADDON_BADGES_SERVICES, ...ADDON_CALENDAR_SERVICES, - ...ADDON_COMPETENCY_SERVICES, ...ADDON_MESSAGEOUTPUT_SERVICES, ...ADDON_MESSAGES_SERVICES, ...ADDON_MOD_ASSIGN_SERVICES, @@ -407,6 +406,7 @@ export class CoreCompileProvider { */ async getLazyLibraries(): Promise[]> { const ADDON_MOD_WORKSHOP_SERVICES = await getWorkshopServices(); + const ADDON_COMPETENCY_SERVICES = await getCompetencyServices(); const ADDON_COURSECOMPLETION_SERVICES = await getCourseCompletionServices(); const CORE_COMMENTS_SERVICES = await getCommentsServices(); @@ -414,6 +414,7 @@ export class CoreCompileProvider { return [ ...ADDON_MOD_WORKSHOP_SERVICES, + ...ADDON_COMPETENCY_SERVICES, ...ADDON_COURSECOMPLETION_SERVICES, ...CORE_COMMENTS_SERVICES, ...CORE_TAG_SERVICES,