diff --git a/src/core/features/block/components/side-blocks-button/side-blocks-button.ts b/src/core/features/block/components/side-blocks-button/side-blocks-button.ts index bc62226d7..74027b05a 100644 --- a/src/core/features/block/components/side-blocks-button/side-blocks-button.ts +++ b/src/core/features/block/components/side-blocks-button/side-blocks-button.ts @@ -33,6 +33,7 @@ export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy { @Input() contextLevel!: string; @Input() instanceId!: number; + @Input() myDashboardPage?: string; userTour: CoreUserTourDirectiveOptions = { id: 'side-blocks-button', @@ -69,6 +70,7 @@ export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy { componentProps: { contextLevel: this.contextLevel, instanceId: this.instanceId, + myDashboardPage: this.myDashboardPage, }, }); } diff --git a/src/core/features/block/components/side-blocks/side-blocks.ts b/src/core/features/block/components/side-blocks/side-blocks.ts index 56624490f..5a7fc3494 100644 --- a/src/core/features/block/components/side-blocks/side-blocks.ts +++ b/src/core/features/block/components/side-blocks/side-blocks.ts @@ -34,6 +34,7 @@ export class CoreBlockSideBlocksComponent implements OnInit { @Input() contextLevel!: string; @Input() instanceId!: number; + @Input() myDashboardPage?: string; @ViewChildren(CoreBlockComponent) blocksComponents?: QueryList; @@ -83,7 +84,7 @@ export class CoreBlockSideBlocksComponent implements OnInit { if (this.contextLevel === 'course') { this.blocks = await CoreBlockHelper.getCourseBlocks(this.instanceId); } else { - const blocks = await CoreCoursesDashboard.getDashboardBlocks(); + const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myDashboardPage); this.blocks = blocks.sideBlocks; } diff --git a/src/core/features/courses/pages/my/my.html b/src/core/features/courses/pages/my/my.html index 1ea788466..1f307e4b7 100644 --- a/src/core/features/courses/pages/my/my.html +++ b/src/core/features/courses/pages/my/my.html @@ -49,6 +49,10 @@ + + + diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index ad8f0a206..56551726e 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -42,6 +42,8 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy { loadedBlock?: Partial; myOverviewBlock?: AddonBlockMyOverviewComponent; loaded = false; + myPageCourses = CoreCoursesDashboardProvider.MY_PAGE_COURSES; + hasSideBlocks = false; protected updateSiteObserver: CoreEventObserver; @@ -79,9 +81,11 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy { if (available && !disabled) { try { - const blocks = await CoreCoursesDashboard.getDashboardBlocksFromWS(CoreCoursesDashboardProvider.MY_PAGE_COURSES); + const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myPageCourses); - this.loadedBlock = blocks.find((block) => block.name == 'myoverview'); + // My overview block should always be in main blocks, but check side blocks too just in case. + this.loadedBlock = blocks.mainBlocks.concat(blocks.sideBlocks).find((block) => block.name == 'myoverview'); + this.hasSideBlocks = blocks.sideBlocks.length > 0; await CoreUtils.nextTicks(2); diff --git a/src/core/features/courses/services/dashboard.ts b/src/core/features/courses/services/dashboard.ts index 117c8d6df..8a5eb2d84 100644 --- a/src/core/features/courses/services/dashboard.ts +++ b/src/core/features/courses/services/dashboard.ts @@ -92,10 +92,15 @@ export class CoreCoursesDashboardProvider { * * @param userId User ID. Default, current user. * @param siteId Site ID. If not defined, current site. + * @param myPage What my page to return blocks of. Default MY_PAGE_DEFAULT. * @return Promise resolved with the list of blocks. */ - async getDashboardBlocks(userId?: number, siteId?: string): Promise { - const blocks = await this.getDashboardBlocksFromWS(CoreCoursesDashboardProvider.MY_PAGE_DEFAULT, userId, siteId); + async getDashboardBlocks( + userId?: number, + siteId?: string, + myPage = CoreCoursesDashboardProvider.MY_PAGE_DEFAULT, + ): Promise { + const blocks = await this.getDashboardBlocksFromWS(myPage, userId, siteId); let mainBlocks: CoreCourseBlock[] = []; let sideBlocks: CoreCourseBlock[] = [];