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

Communication: Configurable numerical username prefix

    • MOODLE_500_STABLE
    • matrix-user-prefix
    • Hide

      Setup Matrix for Moodle

      1. Clone Andrew's helper repository:

        git clone https://github.com/andrewnicols/moodle-synapse
        cd moodle-synapse
        chmod 777 *_data
        

      2. Run the docker-compose up command:

        docker compose up -d
        

      3. Wait for about 10 seconds for the first run to complete
      4. Run the setup script:

        ./setup.sh
        

      5. Copy the command it outputs
      6. Change into your Moodle directory
      7. Paste in the command, for EXAMPLE:

        cd path/to/moodle
        sed -i '/^require_once.*lib.*setup.php.*$/i require_once("/Users/nicols/git/moodlehq/synapse/moodle-config.php");' config.php
        cd -
        

      8. If you have not done so already, edit your /etc/hosts file to add:

        127.0.0.1 element.container.docker.internal element
        127.0.0.1 synapse.container.docker.internal synapse
        127.0.0.1 keycloak.container.docker.internal keycloak
        

      9. Follow the instructions at https://github.com/andrewnicols/moodle-synapse#trusting to trust the root CA that is used for this.

      Test Moodle changes

      This scenario will test the changes in Moodle and addresses this tracker issue specifically.

      1. ENSURE you have your Matrix set up for Moodle as described above.
      2. ENSURE you are checked out to this patch branch
      3. Log in as admin.
      4. Create a course.
      5. Enable Matrix as the communication provider on the course (More -> Communication)
      6. Configure a custom user prefix.
      7. Create a user with the username '123456'
      8. Enrol the user into the course.
      9. Run cron (this will create the Matrix room and attempt to enrol the user)
      10. CONFIRM there were no errors during cron.
      11. Go to your Matrix client (E.g. Element)
      12. CONFIRM that the user was added to the room and uses the configured prefix.
      13. Go back to Moodle and edit the newly created user's profile.
      14. Locate the 'Communication' section
      15. CONFIRM the value in 'Matrix user id' has the configured prefix prepended to the username. It may look something like this: '@custom123456:localhost'

       

      Show
      Setup Matrix for Moodle Clone Andrew's helper repository: git clone https://github.com/andrewnicols/moodle-synapse cd moodle-synapse chmod 777 *_data Run the docker-compose up command: docker compose up -d Wait for about 10 seconds for the first run to complete Run the setup script: ./setup.sh Copy the command it outputs Change into your Moodle directory Paste in the command, for EXAMPLE : cd path/to/moodle sed -i '/^require_once.*lib.*setup.php.*$/i require_once("/Users/nicols/git/moodlehq/synapse/moodle-config.php");' config.php cd - If you have not done so already, edit your /etc/hosts file to add: 127.0.0.1 element.container.docker.internal element 127.0.0.1 synapse.container.docker.internal synapse 127.0.0.1 keycloak.container.docker.internal keycloak Follow the instructions at https://github.com/andrewnicols/moodle-synapse#trusting to trust the root CA that is used for this. Test Moodle changes This scenario will test the changes in Moodle and addresses this tracker issue specifically. ENSURE you have your Matrix set up for Moodle as described above. ENSURE you are checked out to this patch branch Log in as admin. Create a course. Enable Matrix as the communication provider on the course ( More -> Communication ) Configure a custom user prefix. Create a user with the username '123456' Enrol the user into the course. Run cron (this will create the Matrix room and attempt to enrol the user) CONFIRM there were no errors during cron. Go to your Matrix client (E.g. Element) CONFIRM that the user was added to the room and uses the configured prefix. Go back to Moodle and edit the newly created user's profile. Locate the 'Communication' section CONFIRM the value in 'Matrix user id' has the configured prefix prepended to the username. It may look something like this: '@custom123456:localhost'  
    • Hide

      Code verified against automated checks.

      Checked MDL-85520 using repository: https://github.com/geichelberger/moodle

      More information about this report

      Built on: Fri May 16 19:46:26 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-85520 using repository: https://github.com/geichelberger/moodle main (0 errors / 0 warnings) [branch: matrix-user-prefix | CI Job ] More information about this report Built on: Fri May 16 19:46:26 UTC 2025
    • Show
      Launching automatic jobs for branch matrix-user-prefix https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19381/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66249/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66250/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66251/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66252/ App tests (stable app version) Built on: Mon May 19 12:30:17 UTC 2025

      Moodle uses a fixed prefix when a Moodle username is numeric to create a Matrix user. However, this leads to the problem of the integration not being usable if you want to use an existing Matrix instance that uses a different prefix.

      If an administrator could configure the required prefix, it would enable using existing matrix instances that use a custom prefix.

            gregoreichelberger Gregor Eichelberger
            gregoreichelberger Gregor Eichelberger
            Daniel Ziegenberg Daniel Ziegenberg
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

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