diff --git a/src/addons/mod/assign/services/assign.ts b/src/addons/mod/assign/services/assign.ts index 09f6281dd..c213cb8eb 100644 --- a/src/addons/mod/assign/services/assign.ts +++ b/src/addons/mod/assign/services/assign.ts @@ -1559,6 +1559,7 @@ export type AddonModAssignParticipant = { customfields?: { // User custom fields (also known as user profile fields). type: string; // The type of the custom field - text field, checkbox... value: string; // The value of the custom field. + displayvalue: string; // @since 4.2.Formatted value of the custom field. name: string; // The name of the custom field. shortname: string; // The shortname of the custom field - to be able to build the field class in the code. }[]; diff --git a/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html b/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html index 19b3d16de..3638e01b8 100644 --- a/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html +++ b/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html @@ -2,7 +2,8 @@

{{ field.name }}

-

{{ valueNumber * 1000 | coreFormatDate }}

+

{{ valueNumber * 1000 | coreFormatDate }}

+

{{ displayValue }}

diff --git a/src/addons/userprofilefield/datetime/component/datetime.ts b/src/addons/userprofilefield/datetime/component/datetime.ts index 1a48918f5..c97a0400a 100644 --- a/src/addons/userprofilefield/datetime/component/datetime.ts +++ b/src/addons/userprofilefield/datetime/component/datetime.ts @@ -36,7 +36,8 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField format?: string; min?: string; max?: string; - valueNumber = 0; + valueNumber?: number; + displayValue?: string; monthNames?: string[]; displayTimezone?: string; @@ -46,6 +47,12 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField * @param field Field to render. */ protected initForNonEdit(field: CoreUserProfileField): void { + if (field.displayvalue) { + this.displayValue = field.displayvalue; + + return; + } + this.valueNumber = Number(field.value); } diff --git a/src/core/features/user/classes/base-profilefield-component.ts b/src/core/features/user/classes/base-profilefield-component.ts index d7dbb2907..7730b2c59 100644 --- a/src/core/features/user/classes/base-profilefield-component.ts +++ b/src/core/features/user/classes/base-profilefield-component.ts @@ -69,7 +69,7 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit { * @param field Field to render. */ protected initForNonEdit(field: CoreUserProfileField): void { - this.value = field.value; + this.value = field.displayvalue ?? field.value; } /** diff --git a/src/core/features/user/services/user.ts b/src/core/features/user/services/user.ts index 209fe3c06..267b92123 100644 --- a/src/core/features/user/services/user.ts +++ b/src/core/features/user/services/user.ts @@ -892,6 +892,7 @@ export type CoreUserPreference = { export type CoreUserProfileField = { type: string; // The type of the custom field - text field, checkbox... value: string; // The value of the custom field. + displayvalue: string; // @since 4.2. Formatted value of the custom field. name: string; // The name of the custom field. shortname: string; // The shortname of the custom field - to be able to build the field class in the code. };