diff --git a/src/core/features/user/pages/about/about.html b/src/core/features/user/pages/about/about.html index 876cb5220..6c6d35285 100644 --- a/src/core/features/user/pages/about/about.html +++ b/src/core/features/user/pages/about/about.html @@ -79,7 +79,7 @@
{{ user.country }}
-{{ 'core.timezone' | translate}}
{{ user.timezone }}
diff --git a/src/core/features/user/pages/about/about.ts b/src/core/features/user/pages/about/about.ts index a665e364d..c3f600e04 100644 --- a/src/core/features/user/pages/about/about.ts +++ b/src/core/features/user/pages/about/about.ts @@ -21,7 +21,13 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; -import { CoreUser, CoreUserProfile, USER_PROFILE_PICTURE_UPDATED, USER_PROFILE_REFRESHED } from '@features/user/services/user'; +import { + CoreUser, + CoreUserProfile, + USER_PROFILE_PICTURE_UPDATED, + USER_PROFILE_REFRESHED, + USER_PROFILE_SERVER_TIMEZONE, +} from '@features/user/services/user'; import { CoreUserHelper } from '@features/user/services/user-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreIonLoadingElement } from '@classes/ion-loading'; @@ -50,6 +56,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { encodedAddress?: SafeUrl; canChangeProfilePicture = false; interests?: string[]; + displayTimezone = false; protected userId!: number; protected site!: CoreSite; @@ -120,6 +127,12 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { this.user.address = CoreUserHelper.formatAddress('', user.city, user.country); + const serverTimezone = CoreSites.getCurrentSite()?.getStoredConfig('timezone'); + this.displayTimezone = !!serverTimezone; + if (this.displayTimezone && this.user.timezone === USER_PROFILE_SERVER_TIMEZONE) { + this.user.timezone = serverTimezone; + } + await this.checkUserImageUpdated(); } catch (error) { CoreDomUtils.showErrorModalDefault(error, 'core.user.errorloaduser', true); diff --git a/src/core/features/user/services/user.ts b/src/core/features/user/services/user.ts index 44a8d0d4a..209fe3c06 100644 --- a/src/core/features/user/services/user.ts +++ b/src/core/features/user/services/user.ts @@ -54,6 +54,11 @@ export const USER_PROFILE_REFRESHED = 'CoreUserProfileRefreshed'; */ export const USER_PROFILE_PICTURE_UPDATED = 'CoreUserProfilePictureUpdated'; +/** + * Value set in timezone when using the server's timezone. + */ +export const USER_PROFILE_SERVER_TIMEZONE = '99'; + /** * Service to provide user functionalities. */ diff --git a/src/core/features/user/tests/behat/basic_usage.feature b/src/core/features/user/tests/behat/basic_usage.feature index eb189dc9d..3660b07e8 100755 --- a/src/core/features/user/tests/behat/basic_usage.feature +++ b/src/core/features/user/tests/behat/basic_usage.feature @@ -3,8 +3,8 @@ Feature: Test basic usage of user features Background: Given the following "users" exist: - | username | firstname | lastname | - | student1 | Student | Student | + | username | firstname | lastname | timezone | + | student1 | Student | Student | 99 | Scenario: Complete missing fields Given the following "custom profile fields" exist: @@ -59,3 +59,36 @@ Feature: Test basic usage of user features Then I should find "student1@example.com" in the app And I should find "Student Student" in the app And the UI should match the snapshot + + @lms_from4.2 + Scenario: View timezone in profile + Given the following config values are set as admin: + | timezone | Europe/Madrid | + | forcetimezone | 99 | + And the following "users" exist: + | username | firstname | lastname | timezone | + | student2 | John | Smith | Asia/Shanghai | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student2 | C1 | student | + # @todo MDL-77468 This capability override is needed until the issue is integrated. + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | moodle/user:viewalldetails | Allow | student | Course | C1 | + And I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app + And I press "Student Student" in the app + And I press "Details" in the app + Then I should find "Europe/Madrid" in the app + And I should not find "Asia/Shanghai" in the app + + When I press the back button in the app + And I press the back button in the app + And I press "John Smith" in the app + And I press "Details" in the app + Then I should find "Asia/Shanghai" in the app + And I should not find "Europe/Madrid" in the app diff --git a/src/core/features/user/tests/behat/snapshots/test-basic-usage-of-user-features-view-profile_7.png b/src/core/features/user/tests/behat/snapshots/test-basic-usage-of-user-features-view-profile_7.png index 44588d26e..67a6beb33 100644 Binary files a/src/core/features/user/tests/behat/snapshots/test-basic-usage-of-user-features-view-profile_7.png and b/src/core/features/user/tests/behat/snapshots/test-basic-usage-of-user-features-view-profile_7.png differ