diff --git a/src/addons/mod/lti/components/index/index.ts b/src/addons/mod/lti/components/index/index.ts index c1870a741..5cae00a74 100644 --- a/src/addons/mod/lti/components/index/index.ts +++ b/src/addons/mod/lti/components/index/index.ts @@ -17,8 +17,9 @@ import { IonContent } from '@ionic/angular'; import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { AddonModLti, AddonModLtiLti, AddonModLtiProvider } from '../../services/lti'; +import { AddonModLti, AddonModLtiLti } from '../../services/lti'; import { AddonModLtiHelper } from '../../services/lti-helper'; +import { ADDON_MOD_LTI_COMPONENT } from '../../constants'; /** * Component that displays an LTI entry page. @@ -29,7 +30,7 @@ import { AddonModLtiHelper } from '../../services/lti-helper'; }) export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit { - component = AddonModLtiProvider.COMPONENT; + component = ADDON_MOD_LTI_COMPONENT; pluginName = 'lti'; displayDescription = false; diff --git a/src/addons/mod/lti/constants.ts b/src/addons/mod/lti/constants.ts new file mode 100644 index 000000000..c576c5638 --- /dev/null +++ b/src/addons/mod/lti/constants.ts @@ -0,0 +1,16 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export const ADDON_MOD_LTI_COMPONENT = 'mmaModLti'; +export const ADDON_MOD_LTI_PAGE_NAME = 'mod_lti'; diff --git a/src/addons/mod/lti/lti-lazy.module.ts b/src/addons/mod/lti/lti-lazy.module.ts index 8e172a28c..e1419e852 100644 --- a/src/addons/mod/lti/lti-lazy.module.ts +++ b/src/addons/mod/lti/lti-lazy.module.ts @@ -35,4 +35,4 @@ const routes: Routes = [ AddonModLtiIndexPage, ], }) -export class AddonModLtiLazyModule {} +export default class AddonModLtiLazyModule {} diff --git a/src/addons/mod/lti/lti.module.ts b/src/addons/mod/lti/lti.module.ts index 27cd783da..6e300ddad 100644 --- a/src/addons/mod/lti/lti.module.ts +++ b/src/addons/mod/lti/lti.module.ts @@ -20,14 +20,15 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { AddonModLtiIndexLinkHandler } from './services/handlers/index-link'; import { AddonModLtiListLinkHandler } from './services/handlers/list-link'; -import { AddonModLtiModuleHandler, AddonModLtiModuleHandlerService } from './services/handlers/module'; +import { AddonModLtiModuleHandler } from './services/handlers/module'; import { AddonModLtiPrefetchHandler } from './services/handlers/prefetch'; import { AddonModLtiHelper } from './services/lti-helper'; +import { ADDON_MOD_LTI_PAGE_NAME } from './constants'; const routes: Routes = [ { - path: AddonModLtiModuleHandlerService.PAGE_NAME, - loadChildren: () => import('./lti-lazy.module').then(m => m.AddonModLtiLazyModule), + path: ADDON_MOD_LTI_PAGE_NAME, + loadChildren: () => import('./lti-lazy.module'), }, ]; diff --git a/src/addons/mod/lti/services/handlers/module.ts b/src/addons/mod/lti/services/handlers/module.ts index 2b0eb973c..ed14c1a71 100644 --- a/src/addons/mod/lti/services/handlers/module.ts +++ b/src/addons/mod/lti/services/handlers/module.ts @@ -21,6 +21,7 @@ import { makeSingleton } from '@singletons'; import { AddonModLtiHelper } from '../lti-helper'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreCourse } from '@features/course/services/course'; +import { ADDON_MOD_LTI_PAGE_NAME } from '../../constants'; /** * Handler to support LTI modules. @@ -28,11 +29,9 @@ import { CoreCourse } from '@features/course/services/course'; @Injectable({ providedIn: 'root' }) export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { - static readonly PAGE_NAME = 'mod_lti'; - name = 'AddonModLti'; modName = 'lti'; - protected pageName = AddonModLtiModuleHandlerService.PAGE_NAME; + protected pageName = ADDON_MOD_LTI_PAGE_NAME; supportedFeatures = { [CoreConstants.FEATURE_GROUPS]: false, diff --git a/src/addons/mod/lti/services/handlers/prefetch.ts b/src/addons/mod/lti/services/handlers/prefetch.ts index b8682bb6a..4b4e24880 100644 --- a/src/addons/mod/lti/services/handlers/prefetch.ts +++ b/src/addons/mod/lti/services/handlers/prefetch.ts @@ -17,7 +17,8 @@ import { Injectable } from '@angular/core'; import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; import { CoreCourseAnyModuleData } from '@features/course/services/course'; import { makeSingleton } from '@singletons'; -import { AddonModLti, AddonModLtiProvider } from '../lti'; +import { AddonModLti } from '../lti'; +import { ADDON_MOD_LTI_COMPONENT } from '../../constants'; /** * Handler to prefetch LTIs. LTIs cannot be prefetched, but the handler will be used to invalidate some data on course PTR. @@ -27,7 +28,7 @@ export class AddonModLtiPrefetchHandlerService extends CoreCourseActivityPrefetc name = 'AddonModLti'; modName = 'lti'; - component = AddonModLtiProvider.COMPONENT; + component = ADDON_MOD_LTI_COMPONENT; /** * @inheritdoc diff --git a/src/addons/mod/lti/services/lti.ts b/src/addons/mod/lti/services/lti.ts index dfb411098..ab3ca0547 100644 --- a/src/addons/mod/lti/services/lti.ts +++ b/src/addons/mod/lti/services/lti.ts @@ -26,9 +26,7 @@ import { CoreUrlUtils } from '@services/utils/url'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; - -const ROOT_CACHE_KEY = 'mmaModLti:'; -const LAUNCHER_FILE_NAME = 'lti_launcher.html'; +import { ADDON_MOD_LTI_COMPONENT } from '../constants'; /** * Service that provides some features for LTI. @@ -36,7 +34,8 @@ const LAUNCHER_FILE_NAME = 'lti_launcher.html'; @Injectable({ providedIn: 'root' }) export class AddonModLtiProvider { - static readonly COMPONENT = 'mmaModLti'; + protected static readonly ROOT_CACHE_KEY = 'mmaModLti:'; + protected static readonly LAUNCHER_FILE_NAME = 'lti_launcher.html'; /** * Delete launcher. @@ -44,7 +43,7 @@ export class AddonModLtiProvider { * @returns Promise resolved when the launcher file is deleted. */ deleteLauncher(): Promise { - return CoreFile.removeFile(LAUNCHER_FILE_NAME); + return CoreFile.removeFile(AddonModLtiProvider.LAUNCHER_FILE_NAME); } /** @@ -78,7 +77,7 @@ export class AddonModLtiProvider { ' }; \n' + ' \n'; - const entry = await CoreFile.writeFile(LAUNCHER_FILE_NAME, text); + const entry = await CoreFile.writeFile(AddonModLtiProvider.LAUNCHER_FILE_NAME, text); return CoreFile.getFileEntryURL(entry); } @@ -98,7 +97,7 @@ export class AddonModLtiProvider { const preSets: CoreSiteWSPreSets = { cacheKey: this.getLtiCacheKey(courseId), updateFrequency: CoreSite.FREQUENCY_RARELY, - component: AddonModLtiProvider.COMPONENT, + component: ADDON_MOD_LTI_COMPONENT, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; @@ -121,7 +120,7 @@ export class AddonModLtiProvider { * @returns Cache key. */ protected getLtiCacheKey(courseId: number): string { - return ROOT_CACHE_KEY + 'lti:' + courseId; + return AddonModLtiProvider.ROOT_CACHE_KEY + 'lti:' + courseId; } /** @@ -156,7 +155,7 @@ export class AddonModLtiProvider { * @returns Cache key. */ protected getLtiLaunchDataCacheKey(id: number): string { - return `${ROOT_CACHE_KEY}launch:${id}`; + return `${AddonModLtiProvider.ROOT_CACHE_KEY}launch:${id}`; } /** @@ -276,7 +275,7 @@ export class AddonModLtiProvider { return CoreCourseLogHelper.log( 'mod_lti_view_lti', params, - AddonModLtiProvider.COMPONENT, + ADDON_MOD_LTI_COMPONENT, id, siteId, );