From dcf33d4fc198b410a5779fc50d262d1745d2f039 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 28 Nov 2019 16:40:53 +0100 Subject: [PATCH] MOBILE-3235 blocks: Fix activities block outside of course context level --- .../components/activitymodules/activitymodules.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts b/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts index 566ddc0b8..512e93b52 100644 --- a/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts +++ b/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts @@ -18,6 +18,7 @@ import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate import { CoreBlockBaseComponent } from '@core/block/classes/base-block-component'; import { CoreConstants } from '@core/constants'; import { TranslateService } from '@ngx-translate/core'; +import { CoreSitesProvider } from '@providers/sites'; /** * Component to render an "activity modules" block. @@ -36,7 +37,8 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i protected fetchContentDefaultError = 'Error getting activity modules data.'; constructor(injector: Injector, protected courseProvider: CoreCourseProvider, - protected translate: TranslateService, protected moduleDelegate: CoreCourseModuleDelegate) { + protected translate: TranslateService, protected moduleDelegate: CoreCourseModuleDelegate, + protected sitesProvider: CoreSitesProvider) { super(injector, 'AddonBlockActivityModulesComponent'); } @@ -63,8 +65,11 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i * @return Promise resolved when done. */ protected fetchContent(): Promise { - return this.courseProvider.getSections(this.instanceId, false, true).then((sections) => { + const courseId = this.contextLevel === 'course' + ? this.instanceId + : this.sitesProvider.getCurrentSiteHomeId(); + return this.courseProvider.getSections(courseId, false, true).then((sections) => { this.entries = []; const archetypes = {},