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

Update Matrix room membership based on Course enrolment status

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Minor Minor
    • None
    • 4.2
    • Course
    • MOODLE_402_STABLE
    • MDL-76703-master
    • Hide

      Covered by unit tests in this issue and in MDL-76708 (there is a lot of overlap between these issues)

      Environment setup

      Setup the environment using the following link: https://github.com/mattporritt/moodle-docker
      (Feel free to reach out for any issues)

      Make sure you have access to the following information:

      • Element web URL (e.g. https://element:8081)
      • Home server URL (e.g. https://synapse:8008)
      • Mock server URL (e.g. http://localhost:8001) -> Symfony home page
      • Access token, generated using the same account used to login to element client
      • Refresh token (optional)
      • Run the ad-hoc task once all setup is completed and moodle is installed

       

      Note
      There is a step in the environment setup that allows the use of Keycloak to access both Moodle and Matrix with the same oAuth account. This can be handy if you are trying to gain access to Element as a non-admin in this test.

      1. Site admin setting

      1. Login to Moodle as admin
      2. Navigate to Site admin > Development > Experimental settings and enable 'Enable communication subsystem'
      3. Navigate to Site admin > Plugins > Communication > Manage communication providers and ensure 'Matrix' is enabled.
      4. Navigate to Site admin > Plugins > Communication > Matrix
      5. Add the access token (available from the environment setup)
      6. Add the refresh token if available, otherwise paste the access token
      7. Add the element server url (available from the environment setup)
      8. Save your changes
      9. Navigate to Site admin > HTTP Security
      10. Add the Synapse port to 'cURL allowed ports list' (e.g. 8008)

      2. Creating a course with a new room

      1. Create a new course as Admin
      2. Add all the required information in the form
      3. Go to the communication section of the form
      4. Set communication provider to 'Matrix'
      5. Enter a name for the provider room
      6. Save changes
      7. Run the ad-hoc task or the cron itself
      8. Go to https://element:8081
      9. Verify that a new room is created (same as the one you specified)

      3. Enrol user

      1. Make sure you have some un-enrolled users. (If you have some Keycloak users, log in to Moodle with these accounts to get them in the system)
      2. Go back to the created course
      3. Go to Participants and click on "Enrol Users" and add some users
      4. Set the "Assign role" to "Student" then press "Enrol users"
      5. Run the ad-hoc task or the cron itself
      6. Go to https://element:8081
      7. Choose the room that was just created in #2
      8. Verify that new students have been added to the room. If you are having trouble accessing the Matrix room as a student, log into Matrix as the Admin and navigate to the room. You should see 'User X joined the room', etc.

      4. Unenrol user

      1. Go back to the created course
      2. Go to Participants and click on "Trash icon" to unenrol a user from the course
      3. When the popup is shown, click on "Unenrol"
      4. Run the ad-hoc task or the cron itself
      5. Go to https://element:8081
      6. Click on the room where the users were removed
      7. Verify that the targeted users have been removed from the room

      5. Disabling the communication provider

      1. Go back to the created course
      2. Make sure you have a couple of users enrolled in your course
      3. Make sure they are members of a Matrix room by either observing the feed in your room as an Admin, or by checking individual access as a student.
      4. Edit your course settings and go to the 'Communication' section
      5. Set 'Provider' to 'None'
      6. Save changes
      7. Run the ad-hoc task or the cron itself
      8. Verify that the students have lost access to the room, but the admin still has access.
      9. Edit the course settings again and change the provider back to 'Matrix'
      10. Save changes
      11. Run the ad-hoc task or the cron itself
      12. Verify that the students have regained access to the room.

      6. Disabling enrolment method

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Go back to the created course
      3. Click on 'Participants'
      4. Choose 'Enrolment methods' from the dropdown.
      5. Click the 'eye' icon next to 'Manual enrolments'
      6. Run the ad-hoc task or the cron itself
      7. Verify that the students have lost access to the room, but the admin still has access.
      8. Re-enable the enrolment method by clicking the 'eye' icon again.
      9. Run the ad-hoc task or the cron itself
      10. Verify that the students have regained access to the room.

      6. Suspending a user enrolment

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Go back to the created course
      3. Click on 'Participants'
      4. Click the 'cog' icon next to one of the students
      5. Choose 'Suspended' from the Status dropdown and click 'Save changes'.
      6. Run the ad-hoc task or the cron itself
      7. Verify that the student has lost access to the room.
      8. Undo the enrolment suspension by clicking the 'cog' icon again and choosing 'Active'. Click 'Save changes'.
      9. Run the ad-hoc task or the cron itself
      10. Verify that the student has regained access to the room.

      6. Deleting a user enrolment

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Go back to the created course
      3. Click on 'Participants'
      4. Click the 'trash can' icon next to one of the students
      5. Confirm by clicking 'Unenrol'
      6. Run the ad-hoc task or the cron itself
      7. Verify that the student has lost access to the room.

      6. Suspending a user account

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Navigate to Site admin->Browse list of users
      3. Suspend/disable one of the students account by clicking the 'eye' icon
      4. Run the ad-hoc task or the cron itself
      5. Verify that the student has lost access to the room.
      6. Re-enable the student account by clicking the 'eye' icon again.
      7. Run the ad-hoc task or the cron itself
      8. Verify that the student has regained access to the room.

      7. Deleting a user account

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Navigate to Site admin->Browse list of users
      3. Delete one of the students account by clicking the 'trash can' icon
      4. Run the ad-hoc task or the cron itself
      5. Verify that the student has lost access to the room.

      6. Deleting an enrolment method

      1. Make sure you have a course with some users who have access to a Matrix room still.
      2. Go back to the created course
      3. Click on 'Participants'
      4. Choose 'Enrolment methods' from the dropdown.
      5. Click the 'trash can' icon next to 'Manual enrolments'
      6. Run the ad-hoc task or the cron itself
      7. Verify that the students have lost access to the room, but the admin still has access.

      8. Unit testing (with mock server)

      1. Run the command "docker exec -it <webserver_container_id> bash
      2. Initialise phpunit php admin/tool/phpunit/cli/init.php    
      3. Run the following testsuite:
        vendor/bin/phpunit --testsuite communication_matrix_testsuite
      4. Confirm the tests ran successfully
      Show
      Covered by unit tests in this issue and in MDL-76708 (there is a lot of overlap between these issues) Environment setup Setup the environment using the following link:  https://github.com/mattporritt/moodle-docker (Feel free to reach out for any issues) Make sure you have access to the following information: Element web URL (e.g. https://element:8081) Home server URL (e.g. https://synapse:8008 ) Mock server URL (e.g. http://localhost:8001 ) -> Symfony home page Access token, generated using the same account used to login to element client Refresh token (optional) Run the ad-hoc task once all setup is completed and moodle is installed   Note There is a step in the environment setup that allows the use of Keycloak to access both Moodle and Matrix with the same oAuth account. This can be handy if you are trying to gain access to Element as a non-admin in this test. 1. Site admin setting Login to Moodle as admin Navigate to  Site admin > Development > Experimental settings  and enable 'Enable communication subsystem' Navigate to  Site admin > Plugins > Communication > Manage communication providers and ensure 'Matrix' is enabled. Navigate to  Site admin > Plugins > Communication > Matrix Add the access token (available from the environment setup) Add the refresh token if available, otherwise paste the access token Add the element server url (available from the environment setup) Save your changes Navigate to  Site admin > HTTP Security Add the Synapse port to 'cURL allowed ports list' (e.g. 8008) 2. Creating a course with a new room Create a new course as Admin Add all the required information in the form Go to the communication section of the form Set communication provider to 'Matrix' Enter a name for the provider room Save changes Run the ad-hoc task or the cron itself Go to https://element:8081 Verify that a new room is created (same as the one you specified) 3. Enrol user Make sure you have some un-enrolled users. (If you have some Keycloak users, log in to Moodle with these accounts to get them in the system) Go back to the created course Go to Participants and click on "Enrol Users" and add some users Set the "Assign role" to "Student" then press "Enrol users" Run the ad-hoc task or the cron itself Go to https://element:8081 Choose the room that was just created in #2 Verify that new students have been added to the room. If you are having trouble accessing the Matrix room as a student, log into Matrix as the Admin and navigate to the room. You should see 'User X joined the room', etc. 4. Unenrol user Go back to the created course Go to Participants and click on "Trash icon" to unenrol a user from the course When the popup is shown, click on "Unenrol" Run the ad-hoc task or the cron itself Go to https://element:8081 Click on the room where the users were removed Verify that the targeted users have been removed from the room 5. Disabling the communication provider Go back to the created course Make sure you have a couple of users enrolled in your course Make sure they are members of a Matrix room by either observing the feed in your room as an Admin, or by checking individual access as a student. Edit your course settings and go to the 'Communication' section Set 'Provider' to 'None' Save changes Run the ad-hoc task or the cron itself Verify that the students have lost access to the room, but the admin still has access. Edit the course settings again and change the provider back to 'Matrix' Save changes Run the ad-hoc task or the cron itself Verify that the students have regained access to the room. 6. Disabling enrolment method Make sure you have a course with some users who have access to a Matrix room still. Go back to the created course Click on 'Participants' Choose 'Enrolment methods' from the dropdown. Click the 'eye' icon next to 'Manual enrolments' Run the ad-hoc task or the cron itself Verify that the students have lost access to the room, but the admin still has access. Re-enable the enrolment method by clicking the 'eye' icon again. Run the ad-hoc task or the cron itself Verify that the students have regained access to the room. 6. Suspending a user enrolment Make sure you have a course with some users who have access to a Matrix room still. Go back to the created course Click on 'Participants' Click the 'cog' icon next to one of the students Choose 'Suspended' from the Status dropdown and click 'Save changes'. Run the ad-hoc task or the cron itself Verify that the student has lost access to the room. Undo the enrolment suspension by clicking the 'cog' icon again and choosing 'Active'. Click 'Save changes'. Run the ad-hoc task or the cron itself Verify that the student has regained access to the room. 6. Deleting a user enrolment Make sure you have a course with some users who have access to a Matrix room still. Go back to the created course Click on 'Participants' Click the 'trash can' icon next to one of the students Confirm by clicking 'Unenrol' Run the ad-hoc task or the cron itself Verify that the student has lost access to the room. 6. Suspending a user account Make sure you have a course with some users who have access to a Matrix room still. Navigate to Site admin->Browse list of users Suspend/disable one of the students account by clicking the 'eye' icon Run the ad-hoc task or the cron itself Verify that the student has lost access to the room. Re-enable the student account by clicking the 'eye' icon again. Run the ad-hoc task or the cron itself Verify that the student has regained access to the room. 7. Deleting a user account Make sure you have a course with some users who have access to a Matrix room still. Navigate to Site admin->Browse list of users Delete one of the students account by clicking the 'trash can' icon Run the ad-hoc task or the cron itself Verify that the student has lost access to the room. 6. Deleting an enrolment method Make sure you have a course with some users who have access to a Matrix room still. Go back to the created course Click on 'Participants' Choose 'Enrolment methods' from the dropdown. Click the 'trash can' icon next to 'Manual enrolments' Run the ad-hoc task or the cron itself Verify that the students have lost access to the room, but the admin still has access. 8. Unit testing (with mock server) Run the command "docker exec -it <webserver_container_id> bash Initialise phpunit php admin/tool/phpunit/cli/init.php     Run the following testsuite: vendor/bin/phpunit --testsuite communication_matrix_testsuite Confirm the tests ran successfully
    • 6
    • Team Hedgehog Sprint 2.1, Team Hedgehog Sprint 2.2

      When a student’s enrolment status in a Moodle course is changed we want to update the students participation in the associated Matrix room.

      Moodle has 3 enrolment states for a course:

      • Not enrolled: The user is not in a course. They cannot view the content of the course of interact with any course activities, or other course participants
      • Enrolled: The user is in the course and can participate and communicate with others.
      • Suspended. The user is enrolled in the course and appears in the courses participant list. Any actions they did in the course before being suspended remain. However the user cannot access the course.

      It will need to be confirmed which action we undertake in Matrix when a student's enrolment status changes. Matrix has several room operations related to this:

      • Mute: This keeps the user in the room so they can still access the room and watch the content that is posted. But they cannot post any messages themselves in the room
      • Remove from room: As it says, remove the user from the room. If the room is public the user can rejoin anytime. If the room is private the user needs to be reinvited or re added
      • Ban: When a user is banned they cannot rejoin the room or be added until the ban is removed
      • Remove recent messages: This is more of a moderation access than an action related to adding or removing users. Admins can remove a configurable number of the user's most recent messages.

      More information can be found: https://matrix.org/docs/guides/moderation#moderating-rooms

      As per the below the user story, an initial implementation makes sense to add a student to the Matrix room when they have an active enrolment in a course and remove them from the room when they are suspended or unenrolled from the Moodle course.

      From an implementation perspective there should be an event observer that listens for user enrollment change events that then triggers an ad hoc task to update the room membership via Matrix API. While this operation should almost always be instantaneous, we don’t want to block operations in Moodle, waiting for a server that could be on another network or unavailable.

      User stories:

      1. As a teacher I want students invited and removed from my courses room in Matrix based on their enrolment status in my Moodle course. Where an active enrollment means they are in the room, and a suspended or not enrolled status meaning they are not in the room. So that only students with active enrolments can participate.

            david.woloszyn@moodle.com David Woloszyn
            matt.porritt@moodle.com Matt Porritt
            Safat Shahin Safat Shahin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week, 3 days, 7 minutes
                1w 3d 7m

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