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

Create dynamic form fields feature for communication plugins

    XMLWordPrintable

Details

    • MOODLE_402_STABLE
    • MOODLE_403_STABLE
    • MDL-77357-master
    • Hide

      Initial setup for testing:

      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 server and URL of the server, login to the server using the admin account
      • Access token, generated using the same account used to login to element client
      • Synapse server URL
      • Refresh token (optional)
      • Add the following port in the curlsecurityallowedport (admin/settings.php?section=httpsecurity):
        8008

      Unit testing:

      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
      5. Run the following testsuite:
        vendor/bin/phpunit --testsuite core_communication_testsuite
      6. Confirm the tests ran successfully

      Test scenarios

      Create room:

      1. Navigate to the Moodle instance.
      2. Navigate to Site admin > Development > Experimental settings and enable 'Enable communication subsystem'
      3. Navigate to Site admin > Plugins > Communication > Matrix > Settings
      4. Add the synapse server url (available from the environment setup)
      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. Navigate to the create a new course form
      9. Add all the required information in form
      10. Upload a course image
      11. Go to the communication section
      12. Select Matrix as Communication Service
      13. Enter the name of the provider room
      14. Confirm that the Room topic field is visible
      15. Enter the topic of the provider room
      16. Save changes
      17. Run the ad-hoc task or the cron itself: php admin/cli/cron.php
      18. Navigate to the element client
      19. Confirm a new room following the room name
      20. Confirm a new topic following the room topic
      21. Confirm the new room has the avatar set same as the course image

      Update room:

      1. Navigate to the Moodle instance.
      2. Edit the newly created course
      3. Upload a new course image
      4. Go to the communication section
      5. Confirm Matrix is selected as provider
      6. Change the name of the provider room
      7. Change the name of the provider topic
      8. Save changes
      9. Run the ad-hoc task or the cron itself: php admin/cli/cron.php
      10. Navigate to the element client
      11. Confirm the room following the room name
      12. Confirm the room following the room topic{}
      13. Confirm the new room has the avatar set same as the course image

      Added data immediately available:

      1. Navigate to the create a new course form
      2. Add all the required information in form
      3. Upload a course image
      4. Go to the communication section
      5. Select Matrix as Communication Service
      6. Enter the name of the provider room
      7. Confirm that the Room topic field is visible
      8. Enter the topic of the provider room
      9. Save changes
      10. Click settings option for this course
      11. Go to the communication section
      12. Confirm the added room name is available in form field
      13. Confirm the added room topic is available in form field
      14. Change the name of the provider room
      15. Change the name of the provider topic
      16. Save changes
      17. Click settings option for this course
      18. Go to the communication section
      19. Confirm the updated room name is available in form field
      20. Confirm the updated room topic is available in form field

       

      Show
      Initial setup for testing: 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 server and URL of the server, login to the server using the admin account Access token, generated using the same account used to login to element client Synapse server URL Refresh token (optional) Add the following port in the curlsecurityallowedport (admin/settings.php?section=httpsecurity): 8008 Unit testing: 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 Run the following testsuite: vendor/bin/phpunit --testsuite core_communication_testsuite Confirm the tests ran successfully Test scenarios Create room: Navigate to the Moodle instance. Navigate to Site admin > Development > Experimental settings and enable 'Enable communication subsystem' Navigate to Site admin > Plugins > Communication > Matrix > Settings Add the synapse server url (available from the environment setup) 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) Navigate to the create a new course form Add all the required information in form Upload a course image Go to the communication section Select Matrix as Communication Service Enter the name of the provider room Confirm that the Room topic field is visible Enter the topic of the provider room Save changes Run the ad-hoc task or the cron itself: php admin/cli/cron.php Navigate to the element client Confirm a new room following the room name Confirm a new topic following the room topic Confirm the new room has the avatar set same as the course image Update room: Navigate to the Moodle instance. Edit the newly created course Upload a new course image Go to the communication section Confirm Matrix is selected as provider Change the name of the provider room Change the name of the provider topic Save changes Run the ad-hoc task or the cron itself: php admin/cli/cron.php Navigate to the element client Confirm the room following the room name Confirm the room following the room topic { } Confirm the new room has the avatar set same as the course image Added data immediately available: Navigate to the create a new course form Add all the required information in form Upload a course image Go to the communication section Select Matrix as Communication Service Enter the name of the provider room Confirm that the Room topic field is visible Enter the topic of the provider room Save changes Click settings option for this course Go to the communication section Confirm the added room name is available in form field Confirm the added room topic is available in form field Change the name of the provider room Change the name of the provider topic Save changes Click settings option for this course Go to the communication section Confirm the updated room name is available in form field Confirm the updated room topic is available in form field  
    • 6
    • Team Hedgehog Sprint 2.2, Team Hedgehog 2023 Sprint 1.3, Team Hedgehog 2023 Sprint 1.4, Team Hedgehog 2023 Sprint 2.0, Team Hedgehog 2023 Sprint 2.1, Team Hedgehog 2023 Sprint 2.2
    • Medium

    Description

      Create a dynamic form fields api for communication plugin so that plugins can define their own form elements in the communication settings when selected. For example, Matrix plugin should be able to allow adding Room topic as a field in the communication settings when matrix is selected.

      As POC, implement this api in matrix and update room topic from matrix.

      Some important information:

      Create Room

      Create a new room from scratch:

      curl --header "Authorization: Bearer syt_YWRtaW4_MGZMsmjMJocVcXpZbEIV_0V1eZi" \

      -XPOST -d '{"name":"newroom","topic":"room made by api","visibility":"public","preset":"public_chat","room_alias_name":"newroom","initial_state":[]}' \

      "http://synapse:8008/_Matrix/client/r0/createRoom"

       

      The response is like:

      {"room_id":"!bYolbGubJnMDhJiPnz:synapse","room_alias":"#newroom:synapse"}

      We’ll need to store both the room_id and room_alias in Moodle

       

      A further example that sets up end to end encryption for a room:

      curl 'https://synapse:8008/_matrix/client/r0/createRoom' -X POST -H 'Authorization: Bearer syt_YWRtaW4_KXUwoITuowupgGEIGNuK_4MLu3S'  -d '{"name":"curl room","topic":"curly topic","preset":"private_chat","visibility":"private","initial_state":\\\{"type":"m.room.encryption","state_key":"","content":{"algorithm":"m.megolm.v1.aes-sha2"}}}'

      Documentation specific to this process is here: https://spec.matrix.org/v1.5/client-server-api/#post_matrixclientv3createroom 

      Update Room

      Make changes to the room's details. Most room details can only be changed one at a time. For example changing a room name and topic are two separate API calls.

      Changing a room topic:

      curl 'https://synapse:8008/_matrix/client/r0/rooms/!IWCtGkszxDkBUrIsGg%3Asynapse/state/m.room.topic/' -X PUT -H 'Authorization: Bearer syt_YWRtaW4_KXUwoITuowupgGEIGNuK_4MLu3S' -d '{"topic":"the topic updated"}'

      Attachments

        1. MDL-77357-3-12.png
          MDL-77357-3-12.png
          25 kB
        2. MDL-77357-3-19.png
          MDL-77357-3-19.png
          26 kB
        3. MDL-77357-3-7.png
          MDL-77357-3-7.png
          27 kB
        4. MDL-77357-create-14.png
          MDL-77357-create-14.png
          25 kB
        5. MDL-77357-create-19.png
          MDL-77357-create-19.png
          29 kB
        6. MDL-77357-test-unit.png
          MDL-77357-test-unit.png
          73 kB
        7. MDL-77357-update-11a.png
          MDL-77357-update-11a.png
          79 kB
        8. MDL-77357-update-11b.png
          MDL-77357-update-11b.png
          30 kB

        Issue Links

          Activity

            People

              safat.shahin@moodle.com Safat Shahin
              safat.shahin@moodle.com Safat Shahin
              Stevani Andolo Stevani Andolo
              Andrew Lyons Andrew Lyons
              Kevin Percy Kevin Percy
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 6 hours, 57 minutes
                  1d 6h 57m

                  Clockify

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