MOBILE-4616 lti: Move lti constants to a file
parent
7e37b47fd4
commit
df814d022c
|
@ -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;
|
||||
|
||||
|
|
|
@ -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';
|
|
@ -35,4 +35,4 @@ const routes: Routes = [
|
|||
AddonModLtiIndexPage,
|
||||
],
|
||||
})
|
||||
export class AddonModLtiLazyModule {}
|
||||
export default class AddonModLtiLazyModule {}
|
||||
|
|
|
@ -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'),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void> {
|
||||
return CoreFile.removeFile(LAUNCHER_FILE_NAME);
|
||||
return CoreFile.removeFile(AddonModLtiProvider.LAUNCHER_FILE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +77,7 @@ export class AddonModLtiProvider {
|
|||
' }; \n' +
|
||||
'</script> \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,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue