diff --git a/src/addon/mod/h5pactivity/components/components.module.ts b/src/addon/mod/h5pactivity/components/components.module.ts new file mode 100644 index 000000000..7259d8935 --- /dev/null +++ b/src/addon/mod/h5pactivity/components/components.module.ts @@ -0,0 +1,45 @@ +// (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. + +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { IonicModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreComponentsModule } from '@components/components.module'; +import { CoreDirectivesModule } from '@directives/directives.module'; +import { CoreCourseComponentsModule } from '@core/course/components/components.module'; +import { AddonModH5PActivityIndexComponent } from './index/index'; + +@NgModule({ + declarations: [ + AddonModH5PActivityIndexComponent, + ], + imports: [ + CommonModule, + IonicModule, + TranslateModule.forChild(), + CoreComponentsModule, + CoreDirectivesModule, + CoreCourseComponentsModule + ], + providers: [ + ], + exports: [ + AddonModH5PActivityIndexComponent, + ], + entryComponents: [ + AddonModH5PActivityIndexComponent, + ] +}) +export class AddonModH5PActivityComponentsModule {} diff --git a/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html b/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html new file mode 100644 index 000000000..9ce7786b3 --- /dev/null +++ b/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/addon/mod/h5pactivity/components/index/index.ts b/src/addon/mod/h5pactivity/components/index/index.ts new file mode 100644 index 000000000..37cd71688 --- /dev/null +++ b/src/addon/mod/h5pactivity/components/index/index.ts @@ -0,0 +1,83 @@ +// (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. + +import { Component, Optional, Injector } from '@angular/core'; +import { Content } from 'ionic-angular'; +import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component'; +import { AddonModH5PActivity, AddonModH5PActivityProvider, AddonModH5PActivityData } from '../../providers/h5pactivity'; + +/** + * Component that displays an H5P activity entry page. + */ +@Component({ + selector: 'addon-mod-h5pactivity-index', + templateUrl: 'addon-mod-h5pactivity-index.html', +}) +export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActivityComponent { + component = AddonModH5PActivityProvider.COMPONENT; + moduleName = 'h5pactivity'; + + h5pActivity: AddonModH5PActivityData; // The H5P activity object. + + protected fetchContentDefaultError = 'addon.mod_h5pactivity.errorgetactivity'; + + constructor(injector: Injector, + @Optional() protected content: Content) { + super(injector, content); + } + + /** + * Component being initialized. + */ + ngOnInit(): void { + super.ngOnInit(); + + this.loadContent(); + } + + /** + * Check the completion. + */ + protected checkCompletion(): void { + this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); + } + + /** + * Get the activity data. + * + * @param refresh If it's refreshing content. + * @param sync If it should try to sync. + * @param showErrors If show errors to the user of hide them. + * @return Promise resolved when done. + */ + protected async fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise { + try { + this.h5pActivity = await AddonModH5PActivity.instance.getH5PActivity(this.courseId, this.module.id); + + this.description = this.h5pActivity.intro; + this.dataRetrieved.emit(this.h5pActivity); + } finally { + this.fillContextMenu(refresh); + } + } + + /** + * Perform the invalidate content function. + * + * @return Resolved when done. + */ + protected invalidateContent(): Promise { + return AddonModH5PActivity.instance.invalidateActivityData(this.courseId); + } +} diff --git a/src/addon/mod/h5pactivity/h5pactivity.module.ts b/src/addon/mod/h5pactivity/h5pactivity.module.ts new file mode 100644 index 000000000..f7884921c --- /dev/null +++ b/src/addon/mod/h5pactivity/h5pactivity.module.ts @@ -0,0 +1,43 @@ +// (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. + +import { NgModule } from '@angular/core'; +import { AddonModH5PActivityComponentsModule } from './components/components.module'; +import { AddonModH5PActivityModuleHandler } from './providers/module-handler'; +import { AddonModH5PActivityProvider } from './providers/h5pactivity'; +import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate'; + +// List of providers (without handlers). +export const ADDON_MOD_H5P_ACTIVITY_PROVIDERS: any[] = [ + AddonModH5PActivityProvider, +]; + +@NgModule({ + declarations: [ + ], + imports: [ + AddonModH5PActivityComponentsModule + ], + providers: [ + AddonModH5PActivityProvider, + AddonModH5PActivityModuleHandler, + ] +}) +export class AddonModH5PActivityModule { + constructor(moduleDelegate: CoreCourseModuleDelegate, + moduleHandler: AddonModH5PActivityModuleHandler) { + + moduleDelegate.registerHandler(moduleHandler); + } +} diff --git a/src/addon/mod/h5pactivity/lang/en.json b/src/addon/mod/h5pactivity/lang/en.json new file mode 100644 index 000000000..863053845 --- /dev/null +++ b/src/addon/mod/h5pactivity/lang/en.json @@ -0,0 +1,4 @@ +{ + "errorgetactivity": "Error getting H5P activity data.", + "modulenameplural": "H5P" +} \ No newline at end of file diff --git a/src/addon/mod/h5pactivity/pages/index/index.html b/src/addon/mod/h5pactivity/pages/index/index.html new file mode 100644 index 000000000..420138c97 --- /dev/null +++ b/src/addon/mod/h5pactivity/pages/index/index.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/addon/mod/h5pactivity/pages/index/index.module.ts b/src/addon/mod/h5pactivity/pages/index/index.module.ts new file mode 100644 index 000000000..b75f46b1c --- /dev/null +++ b/src/addon/mod/h5pactivity/pages/index/index.module.ts @@ -0,0 +1,33 @@ +// (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. + +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreDirectivesModule } from '@directives/directives.module'; +import { AddonModH5PActivityComponentsModule } from '../../components/components.module'; +import { AddonModH5PActivityIndexPage } from './index'; + +@NgModule({ + declarations: [ + AddonModH5PActivityIndexPage, + ], + imports: [ + CoreDirectivesModule, + AddonModH5PActivityComponentsModule, + IonicPageModule.forChild(AddonModH5PActivityIndexPage), + TranslateModule.forChild() + ], +}) +export class AddonModH5PActivityIndexPageModule {} diff --git a/src/addon/mod/h5pactivity/pages/index/index.ts b/src/addon/mod/h5pactivity/pages/index/index.ts new file mode 100644 index 000000000..7435400a6 --- /dev/null +++ b/src/addon/mod/h5pactivity/pages/index/index.ts @@ -0,0 +1,49 @@ +// (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. + +import { Component, ViewChild } from '@angular/core'; +import { IonicPage, NavParams } from 'ionic-angular'; +import { AddonModH5PActivityIndexComponent } from '../../components/index/index'; +import { AddonModH5PActivityData } from '../../providers/h5pactivity'; + +/** + * Page that displays an H5P activity. + */ +@IonicPage({ segment: 'addon-mod-h5pactivity-index' }) +@Component({ + selector: 'page-addon-mod-h5pactivity-index', + templateUrl: 'index.html', +}) +export class AddonModH5PActivityIndexPage { + @ViewChild(AddonModH5PActivityIndexComponent) h5pComponent: AddonModH5PActivityIndexComponent; + + title: string; + module: any; + courseId: number; + + constructor(navParams: NavParams) { + this.module = navParams.get('module') || {}; + this.courseId = navParams.get('courseId'); + this.title = this.module.name; + } + + /** + * Update some data based on the H5P activity instance. + * + * @param h5p H5P activity instance. + */ + updateData(h5p: AddonModH5PActivityData): void { + this.title = h5p.name || this.title; + } +} diff --git a/src/addon/mod/h5pactivity/providers/h5pactivity.ts b/src/addon/mod/h5pactivity/providers/h5pactivity.ts new file mode 100644 index 000000000..c9431cddc --- /dev/null +++ b/src/addon/mod/h5pactivity/providers/h5pactivity.ts @@ -0,0 +1,173 @@ +// (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. + +import { Injectable } from '@angular/core'; + +import { CoreSites } from '@providers/sites'; +import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws'; +import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; + +import { makeSingleton, Translate } from '@singletons/core.singletons'; + +/** + * Service that provides some features for H5P activity. + */ +@Injectable() +export class AddonModH5PActivityProvider { + static COMPONENT = 'mmaModH5PActivity'; + + protected ROOT_CACHE_KEY = 'mmaModH5PActivity:'; + + /** + * Get cache key for H5P activity data WS calls. + * + * @param courseId Course ID. + * @return Cache key. + */ + protected getH5PActivityDataCacheKey(courseId: number): string { + return this.ROOT_CACHE_KEY + 'h5pactivity:' + courseId; + } + + /** + * Get an H5P activity with key=value. If more than one is found, only the first will be returned. + * + * @param courseId Course ID. + * @param key Name of the property to check. + * @param value Value to search. + * @param moduleUrl Module URL. + * @param forceCache Whether it should always return cached data. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the activity data. + */ + protected async getH5PActivityByField(courseId: number, key: string, value: any, forceCache?: boolean, siteId?: string) + : Promise { + + const site = await CoreSites.instance.getSite(siteId); + const params = { + courseids: [courseId], + }; + const preSets: CoreSiteWSPreSets = { + cacheKey: this.getH5PActivityDataCacheKey(courseId), + updateFrequency: CoreSite.FREQUENCY_RARELY, + }; + + if (forceCache) { + preSets.omitExpires = true; + } + + const response: AddonModH5PActivityGetByCoursesRresult = + await site.read('mod_h5pactivity_get_h5pactivities_by_courses', params, preSets); + + if (response && response.h5pactivities) { + const currentActivity = response.h5pactivities.find((h5pActivity) => { + return h5pActivity[key] == value; + }); + + if (currentActivity) { + return currentActivity; + } + } + + throw Translate.instance.instant('addon.mod_h5pactivity.errorgetactivity'); + } + + /** + * Get an H5P activity by module ID. + * + * @param courseId Course ID. + * @param cmId Course module ID. + * @param forceCache Whether it should always return cached data. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the activity data. + */ + getH5PActivity(courseId: number, cmId: number, forceCache?: boolean, siteId?: string): Promise { + return this.getH5PActivityByField(courseId, 'coursemodule', cmId, forceCache, siteId); + } + + /** + * Get an H5P activity by instance ID. + * + * @param courseId Course ID. + * @param id Instance ID. + * @param forceCache Whether it should always return cached data. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the activity data. + */ + getH5PActivityById(courseId: number, id: number, forceCache?: boolean, siteId?: string): Promise { + return this.getH5PActivityByField(courseId, 'id', id, forceCache, siteId); + } + + /** + * Invalidates H5P activity data. + * + * @param courseId Course ID. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved when the data is invalidated. + */ + async invalidateActivityData(courseId: number, siteId?: string): Promise { + const site = await CoreSites.instance.getSite(siteId); + + return site.invalidateWsCacheForKey(this.getH5PActivityDataCacheKey(courseId)); + } + + /** + * Delete launcher. + * + * @return Promise resolved when the launcher file is deleted. + */ + async isPluginEnabled(siteId?: string): Promise { + const site = await CoreSites.instance.getSite(siteId); + + return site.wsAvailable('mod_h5pactivity_get_h5pactivities_by_courses'); + } +} + +export class AddonModH5PActivity extends makeSingleton(AddonModH5PActivityProvider) {} + +/** + * Basic data for an H5P activity, exported by Moodle class h5pactivity_summary_exporter. + */ +export type AddonModH5PActivityData = { + id: number; // The primary key of the record. + course: number; // Course id this h5p activity is part of. + name: string; // The name of the activity module instance. + timecreated?: number; // Timestamp of when the instance was added to the course. + timemodified?: number; // Timestamp of when the instance was last modified. + intro: string; // H5P activity description. + introformat: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). + grade?: number; // The maximum grade for submission. + displayoptions: number; // H5P Button display options. + enabletracking: number; // Enable xAPI tracking. + grademethod: number; // Which H5P attempt is used for grading. + contenthash?: string; // Sha1 hash of file content. + coursemodule: number; // Coursemodule. + introfiles: CoreWSExternalFile[]; + package: CoreWSExternalFile[]; + deployedfile?: { + filename?: string; // File name. + filepath?: string; // File path. + filesize?: number; // File size. + fileurl?: string; // Downloadable file url. + timemodified?: number; // Time modified. + mimetype?: string; // File mime type. + }; +}; + +/** + * Result of WS mod_h5pactivity_get_h5pactivities_by_courses. + */ +export type AddonModH5PActivityGetByCoursesRresult = { + h5pactivities: AddonModH5PActivityData[]; + warnings?: CoreWSExternalWarning[]; +}; diff --git a/src/addon/mod/h5pactivity/providers/module-handler.ts b/src/addon/mod/h5pactivity/providers/module-handler.ts new file mode 100644 index 000000000..e6ad04b83 --- /dev/null +++ b/src/addon/mod/h5pactivity/providers/module-handler.ts @@ -0,0 +1,89 @@ +// (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. + +import { Injectable } from '@angular/core'; +import { NavController, NavOptions } from 'ionic-angular'; + +import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate'; +import { CoreCourse } from '@core/course/providers/course'; +import { CoreConstants } from '@core/constants'; + +import { AddonModH5PActivity } from './h5pactivity'; +import { AddonModH5PActivityIndexComponent } from '../components/index/index'; + +/** + * Handler to support H5P activities. + */ +@Injectable() +export class AddonModH5PActivityModuleHandler implements CoreCourseModuleHandler { + name = 'AddonModH5PActivity'; + modName = 'h5pactivity'; + + supportedFeatures = { + [CoreConstants.FEATURE_GROUPS]: true, + [CoreConstants.FEATURE_GROUPINGS]: true, + [CoreConstants.FEATURE_MOD_INTRO]: true, + [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, + [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, + [CoreConstants.FEATURE_MODEDIT_DEFAULT_COMPLETION]: true, + [CoreConstants.FEATURE_GRADE_HAS_GRADE]: true, + [CoreConstants.FEATURE_GRADE_OUTCOMES]: true, + [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, + }; + + /** + * Check if the handler is enabled on a site level. + * + * @return Whether or not the handler is enabled on a site level. + */ + isEnabled(): Promise { + return AddonModH5PActivity.instance.isPluginEnabled(); + } + + /** + * Get the data required to display the module in the course contents view. + * + * @param module The module object. + * @param courseId The course ID. + * @param sectionId The section ID. + * @return Data to render the module. + */ + getData(module: any, courseId: number, sectionId: number): CoreCourseModuleHandlerData { + + return { + icon: CoreCourse.instance.getModuleIconSrc(this.modName, module.modicon), + title: module.name, + class: 'addon-mod_h5pactivity-handler', + action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void { + const pageParams = {module: module, courseId: courseId}; + if (params) { + Object.assign(pageParams, params); + } + navCtrl.push('AddonModH5PActivityIndexPage', pageParams, options); + } + }; + } + + /** + * Get the component to render the module. This is needed to support singleactivity course format. + * The component returned must implement CoreCourseModuleMainComponent. + * + * @param course The course object. + * @param module The module object. + * @return The component to use, undefined if not found. + */ + getMainComponent(course: any, module: any): any { + return AddonModH5PActivityIndexComponent; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8efe0fa31..d78d45edb 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -155,6 +155,7 @@ import { AddonQbehaviourModule } from '@addon/qbehaviour/qbehaviour.module'; import { AddonQtypeModule } from '@addon/qtype/qtype.module'; import { AddonStorageManagerModule } from '@addon/storagemanager/storagemanager.module'; import { AddonFilterModule } from '@addon/filter/filter.module'; +import { AddonModH5PActivityModule } from '@addon/mod/h5pactivity/h5pactivity.module'; import { setSingletonsInjector } from '@singletons/core.singletons'; @@ -303,7 +304,8 @@ export const WP_PROVIDER: any = null; AddonQbehaviourModule, AddonQtypeModule, AddonStorageManagerModule, - AddonFilterModule + AddonFilterModule, + AddonModH5PActivityModule, ], bootstrap: [IonicApp], entryComponents: [ diff --git a/src/assets/img/mod/h5pactivity.svg b/src/assets/img/mod/h5pactivity.svg new file mode 100644 index 000000000..97fef5728 --- /dev/null +++ b/src/assets/img/mod/h5pactivity.svg @@ -0,0 +1 @@ +h5p finalArtboard 1 \ No newline at end of file diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 290fe79f4..b6a848c1f 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -659,6 +659,8 @@ "addon.mod_glossary.noentriesfound": "No entries were found.", "addon.mod_glossary.searchquery": "Search query", "addon.mod_glossary.tagarea_glossary_entries": "Glossary entries", + "addon.mod_h5pactivity.errorgetactivity": "Error getting H5P activity data.", + "addon.mod_h5pactivity.modulenameplural": "H5P", "addon.mod_imscp.deploymenterror": "Content package error!", "addon.mod_imscp.modulenameplural": "IMS content packages", "addon.mod_imscp.showmoduledescription": "Show description", diff --git a/src/core/compile/providers/compile.ts b/src/core/compile/providers/compile.ts index fc8268f61..0c9b84f9a 100644 --- a/src/core/compile/providers/compile.ts +++ b/src/core/compile/providers/compile.ts @@ -109,6 +109,7 @@ import { ADDON_MOD_FEEDBACK_PROVIDERS } from '@addon/mod/feedback/feedback.modul import { ADDON_MOD_FOLDER_PROVIDERS } from '@addon/mod/folder/folder.module'; import { ADDON_MOD_FORUM_PROVIDERS } from '@addon/mod/forum/forum.module'; import { ADDON_MOD_GLOSSARY_PROVIDERS } from '@addon/mod/glossary/glossary.module'; +import { ADDON_MOD_H5P_ACTIVITY_PROVIDERS } from '@addon/mod/h5pactivity/h5pactivity.module'; import { ADDON_MOD_IMSCP_PROVIDERS } from '@addon/mod/imscp/imscp.module'; import { ADDON_MOD_LESSON_PROVIDERS } from '@addon/mod/lesson/lesson.module'; import { ADDON_MOD_LTI_PROVIDERS } from '@addon/mod/lti/lti.module'; @@ -242,7 +243,7 @@ export class CoreCompileProvider { .concat(ADDON_MOD_WORKSHOP_PROVIDERS).concat(ADDON_NOTES_PROVIDERS).concat(ADDON_NOTIFICATIONS_PROVIDERS) .concat(CORE_PUSHNOTIFICATIONS_PROVIDERS).concat(ADDON_REMOTETHEMES_PROVIDERS).concat(CORE_BLOCK_PROVIDERS) .concat(CORE_FILTER_PROVIDERS).concat(CORE_H5P_PROVIDERS).concat(CORE_EDITOR_PROVIDERS) - .concat(CORE_SEARCH_PROVIDERS); + .concat(CORE_SEARCH_PROVIDERS).concat(ADDON_MOD_H5P_ACTIVITY_PROVIDERS); // We cannot inject anything to this constructor. Use the Injector to inject all the providers into the instance. for (const i in providers) { diff --git a/src/core/course/providers/course.ts b/src/core/course/providers/course.ts index 1facbf99f..1af6354bf 100644 --- a/src/core/course/providers/course.ts +++ b/src/core/course/providers/course.ts @@ -30,6 +30,8 @@ import { CoreCourseFormatDelegate } from './format-delegate'; import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; +import { makeSingleton } from '@singletons/core.singletons'; + /** * Service that provides some features regarding a course. */ @@ -98,7 +100,7 @@ export class CoreCourseProvider { protected CORE_MODULES = [ 'assign', 'assignment', 'book', 'chat', 'choice', 'data', 'database', 'date', 'external-tool', 'feedback', 'file', 'folder', 'forum', 'glossary', 'ims', 'imscp', 'label', 'lesson', 'lti', 'page', 'quiz', - 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop' + 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop', 'h5pactivity' ]; constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private eventsProvider: CoreEventsProvider, @@ -1144,6 +1146,8 @@ export class CoreCourseProvider { } } +export class CoreCourse extends makeSingleton(CoreCourseProvider) {} + /** * Data returned by course_summary_exporter. */