From 38ae12fe352845688629f532c53bcee1f6f6f2bd Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Tue, 17 Sep 2024 16:23:15 +0200 Subject: [PATCH] MOBILE-4639 badges: Use ccourse full name returned by WS --- .../badges/pages/issued-badge/issued-badge.html | 4 ++-- .../badges/pages/issued-badge/issued-badge.ts | 17 +++++++++-------- src/addons/badges/services/badges.ts | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/addons/badges/pages/issued-badge/issued-badge.html b/src/addons/badges/pages/issued-badge/issued-badge.html index 34eee5032..7f0aa1ba1 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.html +++ b/src/addons/badges/pages/issued-badge/issued-badge.html @@ -111,11 +111,11 @@

{{ badge.imagecaption }}

- +

{{ 'core.course' | translate}}

- +

diff --git a/src/addons/badges/pages/issued-badge/issued-badge.ts b/src/addons/badges/pages/issued-badge/issued-badge.ts index ff2c0d376..0b94c5874 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.ts +++ b/src/addons/badges/pages/issued-badge/issued-badge.ts @@ -19,7 +19,7 @@ import { CoreSites } from '@services/sites'; import { CoreUser } from '@features/user/services/user'; import { AddonBadges, AddonBadgesUserBadge } from '../../services/badges'; import { CoreUtils } from '@services/utils/utils'; -import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; +import { CoreCourses } from '@features/courses/services/courses'; import { CoreNavigator } from '@services/navigator'; import { ActivatedRoute } from '@angular/router'; import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager'; @@ -30,7 +30,7 @@ import { CoreTime } from '@singletons/time'; import { CoreSharedModule } from '@/core/shared.module'; /** - * Page that displays the list of calendar events. + * Page that displays an issued badge. */ @Component({ selector: 'page-addon-badges-issued-badge', @@ -47,7 +47,6 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy { protected logView: (badge: AddonBadgesUserBadge) => void; courseId = 0; - course?: CoreEnrolledCourseData; badge?: AddonBadgesUserBadge; badges?: CoreSwipeNavigationItemsManager; badgeLoaded = false; @@ -128,16 +127,18 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy { } } - this.badge = badge; - if (badge.courseid) { + // Try to get course full name if not returned by the WS. + if (badge.courseid && !badge.coursefullname) { try { - this.course = await CoreCourses.getUserCourse(badge.courseid, true); + const course = await CoreCourses.getUserCourse(badge.courseid, true); + badge.coursefullname = course.fullname; } catch { - // Maybe an old deleted course. - this.course = undefined; + // User is not enrolled in the course. } } + this.badge = badge; + this.logView(badge); } catch (message) { CoreDomUtils.showErrorModalDefault(message, 'Error getting badge data.'); diff --git a/src/addons/badges/services/badges.ts b/src/addons/badges/services/badges.ts index 2121b3ed6..1642be5b4 100644 --- a/src/addons/badges/services/badges.ts +++ b/src/addons/badges/services/badges.ts @@ -215,6 +215,7 @@ export type AddonBadgesUserBadge = { expireperiod?: number; // Expire period. type?: number; // Type. courseid?: number; // Course id. + coursefullname?: string; // Full name of the course. message?: string; // Message. messagesubject?: string; // Message subject. attachment?: number; // Attachment.