Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-67419

Set language in user profile during account auto-creation based on browser language instead of admin setting

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Notes

      1. Each step requires you to log in with a brand new username. The test data includes 100 users numbered from 1-100 with usernames u1, u2, ... u100. If you need to retest at any point then use a new user (i.e. u11, u12.

      Shared setup (once for all branches under test)

      1. In a terminal:

        git clone git@github.com:andrewnicols/moodle-docker-ldap.git
        cd moodle-docker-ldap
        docker build -t moodle-docker-ldap:latest .
        docker run --rm -p 389:389 --name ldap -t moodle-docker-ldap:latest
        

        Note: Do not close this terminal window until you have finished testing

      1. Login as admin
      2. Go to Site administration > Plugins > Authentication > Manage authentication
      3. Enable LDAP server
      4. Edit settings for "LDAP server":
        • Host URL: ldap://localhost
        • Distinguished name: cn=admin,dc=openstack,dc=org
        • Password: password
        • Contexts: ou=users,dc=openstack,dc=org
        • User attribute: uid
        • Data mapping (First name): cn
        • Data mapping (Surname): sn
        • Data mapping (Email address): mail
        • Data mapping (Description): description
        • Data mapping (Department): ou
      5. Go to Site administration > Plugins > Authentication > Manage authentication and "Test settings" for "LDAP server"
      6. Check "Connecting to your LDAP server was successful" message is displayed

      Setup for each tested branch

      1. Login as admin
      2. Install the Deutsche (de) and Filipino (fil) language packs
        1. For Moodle 3.10 you might need to copy the content in moodledata/lang from your integration_master instance (after installing these languages) to integration_310/moodledata/lang (or whatever will be the moodledata for the 3.10 instance).
      3. Go to Site administration > Language > Language settings
        1. Set "Language autodetect" = Yes
        2. Set "Default language" = Filipino
        3. Set "Use language that is auto detected from users browser during user creation" = Yes
      4. Logout

      Scenario 1 - Browser language matches site default language

      1. Set your preferred browser language to Filipino
      2. Clear your browser caches and cookies
      3. Go to the Moodle login page
        1. Verify that you see Moodle in Filipino as this language was autodetected for you
      4. Login with username u1 and password test
        1. Confirm that after login the language shown was Filipino
      5. Log out

      Scenario 2 - Browser language different to site default language

      1. Set your preferred browser language to English
      2. Clear your browser caches and cookies
      3. Go to the Moodle login page
        1. Verify that you see Moodle in English as this language was autodetected for you
      4. Login with username u2 and password test
        1. Confirm that after login the language shown was English

      Scenario 3 - Current language not installed

      1. Set your preferred browser language to French
      2. Clear your browser caches and cookies
      3. Go to the Moodle login page
        1. Verify that you see Moodle in Filipino as French is not an installed language, and the fallback is Filipino
      4. Login with username u3 and password test
        1. Confirm that after login the language shown was Filipino
      5. Log out

      Scenario 4 - Browser language not considered during account creation

      1. Log in as admin
      2. Go to Site administration > Language > Language settings
        1. Set "Use language that is auto detected from users browser during user creation" = No
      3. Logout
      4. Set your preferred browser language to English
      5. Clear your browser caches and cookies
      6. Go to the Moodle login page
        1. Verify that you see Moodle in English as this language was autodetected for you
          Note: Guest language detection is enabled
      7. Login with username u4 and password test
        1. Confirm that after login the language shown was Filipino
          Note: User language detection is disabled
      8. Log out

      Scenario 5 - Browser language not considered as guest

      1. Log in as admin
      2. Go to Site administration > Language > Language settings
        1. Set "Language autodetect" = No
      3. Logout
      4. Set your preferred browser language to English
      5. Clear your browser caches and cookies
      6. Go to the Moodle login page
        1. Confirm that after login the language shown was Filipino
          Note: Guest language detection is disabled
      7. Login with username u5 and password test
        1. Confirm that after login the language shown was Filipino
          Note: User language detection is disabled
      8. Log out

      Scenario 6 - Users auto-created

      1. Log in as admin
      2. Go to Site administration > Language > Language settings
        1. Set "Language autodetect" = Yes
        2. Set "Use language that is auto detected from users browser during user creation" = Yes
      3. Logout
      4. Open a new Terminal window
      5. Sync all users from LDAP:

        php auth/ldap/cli/sync_users.php
        

        Note: After running this step if you need to retest you will need to delete all LDAP users

        1. Confirm that users were created
      1. Set your preferred browser language to English
      2. Clear your browser caches and cookies
      3. Go to the Moodle login page
        1. Confirm that after login the language shown was English
      4. Login with username u6 and password test
        1. Confirm that after login the language shown was Filipino
          Note: User language detection is enabled, but the user was created with the site default language
      5. Log out

      Scenario 6 Addendum

      If you need to delete all LDAP users you can do so for the purposes of testing by running the following SQL:

      DELETE FROM mdl_user WHERE auth = 'ldap';
      

      Note: This is only suitable for testing this issue
       

      Show
      Notes Each step requires you to log in with a brand new username. The test data includes 100 users numbered from 1-100 with usernames u1 , u2 , ... u100 . If you need to retest at any point then use a new user (i.e. u11 , u12 . Shared setup (once for all branches under test) In a terminal: git clone git@github.com:andrewnicols/moodle-docker-ldap.git cd moodle-docker-ldap docker build -t moodle-docker-ldap:latest . docker run --rm -p 389:389 --name ldap -t moodle-docker-ldap:latest Note: Do not close this terminal window until you have finished testing Login as admin Go to Site administration > Plugins > Authentication > Manage authentication Enable LDAP server Edit settings for "LDAP server": Host URL: ldap://localhost Distinguished name: cn=admin,dc=openstack,dc=org Password: password Contexts: ou=users,dc=openstack,dc=org User attribute: uid Data mapping (First name): cn Data mapping (Surname): sn Data mapping (Email address): mail Data mapping (Description): description Data mapping (Department): ou Go to Site administration > Plugins > Authentication > Manage authentication and "Test settings" for "LDAP server" Check "Connecting to your LDAP server was successful" message is displayed Setup for each tested branch Login as admin Install the Deutsche (de) and Filipino (fil) language packs For Moodle 3.10 you might need to copy the content in moodledata/lang from your integration_master instance (after installing these languages) to integration_310/moodledata/lang (or whatever will be the moodledata for the 3.10 instance). Go to Site administration > Language > Language settings Set "Language autodetect" = Yes Set "Default language" = Filipino Set " Use language that is auto detected from users browser during user creation " = Yes Logout Scenario 1 - Browser language matches site default language Set your preferred browser language to Filipino Clear your browser caches and cookies Go to the Moodle login page Verify that you see Moodle in Filipino as this language was autodetected for you Login with username u1 and password test Confirm that after login the language shown was Filipino Log out Scenario 2 - Browser language different to site default language Set your preferred browser language to English Clear your browser caches and cookies Go to the Moodle login page Verify that you see Moodle in English as this language was autodetected for you Login with username u2 and password test Confirm that after login the language shown was English Scenario 3 - Current language not installed Set your preferred browser language to French Clear your browser caches and cookies Go to the Moodle login page Verify that you see Moodle in Filipino as French is not an installed language, and the fallback is Filipino Login with username u3 and password test Confirm that after login the language shown was Filipino Log out Scenario 4 - Browser language not considered during account creation Log in as admin Go to Site administration > Language > Language settings Set " Use language that is auto detected from users browser during user creation " = No Logout Set your preferred browser language to English Clear your browser caches and cookies Go to the Moodle login page Verify that you see Moodle in English as this language was autodetected for you Note: Guest language detection is enabled Login with username u4 and password test Confirm that after login the language shown was Filipino Note: User language detection is disabled Log out Scenario 5 - Browser language not considered as guest Log in as admin Go to Site administration > Language > Language settings Set " Language autodetect " = No Logout Set your preferred browser language to English Clear your browser caches and cookies Go to the Moodle login page Confirm that after login the language shown was Filipino Note: Guest language detection is disabled Login with username u5 and password test Confirm that after login the language shown was Filipino Note: User language detection is disabled Log out Scenario 6 - Users auto-created Log in as admin Go to Site administration > Language > Language settings Set " Language autodetect " = Yes Set " Use language that is auto detected from users browser during user creation " = Yes Logout Open a new Terminal window Sync all users from LDAP: php auth/ldap/cli/sync_users.php Note: After running this step if you need to retest you will need to delete all LDAP users Confirm that users were created Set your preferred browser language to English Clear your browser caches and cookies Go to the Moodle login page Confirm that after login the language shown was English Login with username u6 and password test Confirm that after login the language shown was Filipino Note: User language detection is enabled, but the user was created with the site default language Log out Scenario 6 Addendum If you need to delete all LDAP users you can do so for the purposes of testing by running the following SQL: DELETE FROM mdl_user WHERE auth = 'ldap'; Note: This is only suitable for testing this issue  
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull Master Branch:
      MDL-67419-master

      Description

      Prerequisites:

      • Use a Moodle instance where user accounts are created automatically upon first login, e.g. from LDAP.
      • Prepare 3 user accounts which will be created on the fly upon first login
      • Login as admin
      • Install the german language pack besides the english language pack
      • Set $CFG-> autolang = true
      • Set $CFG-> lang = German
      • Logout

      Scenario 1

      • Set your preferred browser language to german
      • Clear your browser caches and cookies
      • Go to the Moodle login page
      • Verify that you see Moodle in german as this language was autodetected for you
      • Login with user 1

      Expected result:

      • User 1 will have the german language set in his user profile as this was his preferred browser language when his account was created.

      Actual result:

      • User 1 will have the german language set in his user profile as this is the site's standard language and is used for auto-created new accounts

      Scenario 2

      • Set your preferred browser language to english
      • Clear your browser caches and cookies
      • Go to the Moodle login page
      • Verify that you see Moodle in english as this language was autodetected for you
      • Login with user 2

      Expected result:

      • User 2 will have the english language set in his user profile as this was his preferred browser language when his account was created.

      Actual result:

      • User 2 will have the german language set in his user profile as this is the site's standard language and is used for auto-created new accounts*

      Scenario 3

      • Set your preferred browser language to french
      • Clear your browser caches and cookies
      • Go to the Moodle login page
      • Verify that you see Moodle in german as there isn't a language pack installed for the autodetected french language and as german, the site's standard language, is used as fallback.
      • Login with user 3

      Expected result:

      • User 3 will have the german language set in his user profile as there isn't a language pack installed for his preferred browser language and as german, the site's standard language, is used as fallback.

      Actual result:

      • User 3 will have the german language set in his user profile as this is the site's standard language and is used for auto-created new accounts

      Proposal

      The described actual results of the described scenarios might be fine for some Moodle installation, but there are also installations which expect the expected results. Thus, an admin setting is needed.

      We propose to add a new admin setting to /admin/settings.php?section=langsettings called "Choose user account language during account auto-creation" with these values:

      • Set user account language to browser language (Default for new sites which produces the expected behavior described above)
      • Set user account language to default site language (Default for upgraded sites as it's the current actual behavior)

      Alternatively, $CFG->autolang could be extended to cover the additional needs. It would have to be changed from a checkbox to a dropdown setting.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              farhan6318 Farhan Karmali
              Reporter:
              abias Alexander Bias
              Peer reviewer:
              Mihail Geshoski
              Integrator:
              Andrew Nicols
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, David Mudrák (@mudrd8mz), Helen Foster, Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 3 hours, 55 minutes
                  1d 3h 55m