diff --git a/src/addons/coursecompletion/pages/report/report.ts b/src/addons/coursecompletion/pages/report/report.ts index 027d0480e..dabbf0c54 100644 --- a/src/addons/coursecompletion/pages/report/report.ts +++ b/src/addons/coursecompletion/pages/report/report.ts @@ -31,9 +31,9 @@ import { CoreDomUtils } from '@services/utils/dom'; }) export class AddonCourseCompletionReportPage implements OnInit { - protected courseId!: number; protected userId!: number; + courseId!: number; completionLoaded = false; completion?: AddonCourseCompletionCourseCompletionStatus; showSelfComplete = false; diff --git a/src/core/features/user/services/handlers/profile-link.ts b/src/core/features/user/services/handlers/profile-link.ts index a4b6ce399..34ddfcf1d 100644 --- a/src/core/features/user/services/handlers/profile-link.ts +++ b/src/core/features/user/services/handlers/profile-link.ts @@ -17,6 +17,7 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; +import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; /** @@ -27,7 +28,7 @@ export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBa name = 'CoreUserProfileLinkHandler'; // Match user/view.php and user/profile.php but NOT grade/report/user/. - pattern = /((\/user\/view\.php)|(\/user\/profile\.php)).*([?&]id=\d+)/; + pattern = /(\/user\/view\.php)|(\/user\/profile\.php)/; /** * @inheritdoc @@ -37,11 +38,18 @@ export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBa url: string, params: Record, ): CoreContentLinksAction[] | Promise { + return [{ - action: (siteId): void => { + action: async (siteId): Promise => { + let userId = params.id ? parseInt(params.id, 10) : 0; + if (!userId) { + const site = await CoreSites.getSite(siteId); + userId = site.getUserId(); + } + const pageParams = { courseId: params.course, - userId: parseInt(params.id, 10), + userId, }; CoreNavigator.navigateToSitePath('/user', { params: pageParams, siteId }); @@ -53,7 +61,7 @@ export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBa * @inheritdoc */ async isEnabled(siteId: string, url: string): Promise { - return url.indexOf('/grade/report/') == -1; + return url.indexOf('/grade/report/') === -1; } }