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

Allow course language to be overridden for roles with a given capability

XMLWordPrintable

    • MOODLE_26_STABLE
    • MOODLE_27_STABLE
    • mdl27_mdl-43497_allow_force_language_02
    • Hide

      Setup for tests 1 and 2:

      • have at least two non-english language pack installed (here: fr and ar)
      • create a course "no force lang" that does not force language
      • create a course "force lang" that forces the language to a certain language (e.g. ar)

      1. Test overriding session lang using a get parameter works as before

      • log out and log in again
      • access the front page of the moodle with a get parameter: /?lang=fr
      • access the "no force lang" course. Moodle strings should be shown in french.
      • access the "force lang" course. Moodle strings should be in the course language

      2. Test that it is possible to force the language, overriding the course language

      • test this with a user account that has the moodle/site:forcelanguage capability allowed, and/or as an admin user
      • log out and log in again
      • access the front page of the moodle with a get parameter: /?forcelang=fr
      • access the "no force lang" course. Moodle strings should be shown in french.
      • access the "force lang" course. Moodle strings should be in french.
      • log out and log in again
      • access the "no force lang" course. Moodle strings should be shown in the user's language
      • access the "force lang" course. Moodle strings should be shown in the course language.

      3. Run any/all the following Behat:

      • group/tests/behat/delete_groups.feature
      • group/tests/behat/create_groups.feature
      • course/tests/behat/restrict_available_activities.feature
      Show
      Setup for tests 1 and 2: have at least two non-english language pack installed (here: fr and ar) create a course "no force lang" that does not force language create a course "force lang" that forces the language to a certain language (e.g. ar) 1. Test overriding session lang using a get parameter works as before log out and log in again access the front page of the moodle with a get parameter: /?lang=fr access the "no force lang" course. Moodle strings should be shown in french. access the "force lang" course. Moodle strings should be in the course language 2. Test that it is possible to force the language, overriding the course language test this with a user account that has the moodle/site:forcelanguage capability allowed, and/or as an admin user log out and log in again access the front page of the moodle with a get parameter: /?forcelang=fr access the "no force lang" course. Moodle strings should be shown in french. access the "force lang" course. Moodle strings should be in french. log out and log in again access the "no force lang" course. Moodle strings should be shown in the user's language access the "force lang" course. Moodle strings should be shown in the course language. 3. Run any/all the following Behat: group/tests/behat/delete_groups.feature group/tests/behat/create_groups.feature course/tests/behat/restrict_available_activities.feature

      Whose life this improves: Moodle administrators and Help Desk personnel.

      We've been in a situation several times where a problem was reported on a production, in-use Moodle instance, but we had a hard time to investigate the problem because the course-forced language was one we didn't understand. Usually, if it's a european language, we can more or less understand it. However, no one on our team speaks Arabic, for example.

      The fix suggested (patch provided) here allows the course forced language to be overridden if the user's role has that capability. By default, this is only possible for admin users. This is done the same way that it's done for $SESSION->lang : you specify it in a get parameter, e.g. http://moodle.example.com/?forcelang=en .

      While creating the patch, I investigated all the places where existing Moodle code temporarily changes the current language by setting $SESSION->lang. Everyplace where it made sense (e.g. where the intention is to override the current course and session language), I replaced these with calls to a new function moodle_force_language(), which uses $SESSION->forcelang. $SESSION->forcelang is checked before $course->lang and $SESSION->lang in current_language().

            brianking Brian King
            brianking Brian King
            Dan Poltawski Dan Poltawski
            Sam Hemelryk Sam Hemelryk
            Jason Fowler Jason Fowler
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.