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

Import the Guzzle library in LMS

    XMLWordPrintable

Details

    • MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-76135-master
    • Hide

      Initial setup

      Standup a Moodle instance using the tracker.

      Go to the moodle directory or the root directory where your moodle code lives.

      Download all the uploaded php scripts named mockbin from the tracker and save them in the root directory.

      Basic request

      • Run the simple_test_mockbin.php script using the following command:
        php simple_test_mockbin,php
      • Confirm that the script ran without any error
      • Confirm that the output contains the following information:
        Connection #0 to host mockbin.com left intact
      • Run the simple_test_2_mockbin.php script using the following command:
        php simple_test_2_mockbin,php
      • Confirm that the script ran without any error
      • Confirm that the output contains the following information:
        Connection #0 to host mockbin.com left intact

      Cached request

      • Run the cache_test_mockbin.php script using the following command:
        php cache_test_mockbin.php
      • Confirm that the script ran without any error
      • Confirm that the output contains the following information:
        Connection #0 to host mockbin.com left intact
      • Go to your moodledata directory (Check the config.php in your root directory to confirm the moodledata directory location)
      • Go to cache/core_guzzle directory in your moodledata directory
      • Confirm there is a file with a filename starting with u0_
      • Run the following command to check the file:
        cat u0_name_of_the_file
      • Confirm that you can see the content of the file
      • Confirm that the content of the file contains the following information:
        "url": "http://mockbin.com/request"

      Cookiejar request

      • Run the cookiejar_test_mockbin.php script using the following command:
        php cookiejar_test_mockbin,php
      • Confirm that the script ran without any error
      • Confirm that the output contains the following information: {   "cookies": {     "other_cookie": "barbaz1234",      "some_cookie": "foo"   }

        }

      • Confirm that the output contains the information about the domain:
        Cookie domain: mockbin.com

      Continuous requests

      • Run the basictestguzzle_mockbin.php script using the following command:
        php basictestguzzle_mockbin,php
      • Confirm that the script ran without any error
      • Confirm that all the outputs are available in the console.

      Calendar test

      1. Open calendar/lib.php file.
      2. Replace the function calendar_get_icalendar with this function content.
      3. Login as admin.
      4. Click on User profile menu -> Calendar.
      5. Click on Import or export calendars link.
      6. Click on Import calendar button.
      7. Set the Calendar name to: Test ICS with Guzzle.
      8. Set the  Calendar URL to: https://www.officeholidays.com/ics/vietnam
      9. Click Import calendar button.
      10. Verify that the import process is success.
      11. Navigate back to the Calendar.
      12. Verify that you will see the new imported events.
      13. Remember to revert all the changes for calendar/lib.php file.
      Show
      Initial setup Standup a Moodle instance using the tracker. Go to the moodle directory or the root directory where your moodle code lives. Download all the uploaded php scripts named mockbin from the tracker and save them in the root directory. Basic request Run the simple_test_mockbin.php script using the following command: php simple_test_mockbin,php Confirm that the script ran without any error Confirm that the output contains the following information: Connection #0 to host mockbin.com left intact Run the simple_test_2_mockbin.php script using the following command: php simple_test_2_mockbin,php Confirm that the script ran without any error Confirm that the output contains the following information: Connection #0 to host mockbin.com left intact Cached request Run the cache_test_mockbin.php script using the following command: php cache_test_mockbin.php Confirm that the script ran without any error Confirm that the output contains the following information: Connection #0 to host mockbin.com left intact Go to your moodledata directory (Check the config.php in your root directory to confirm the moodledata directory location) Go to cache/core_guzzle directory in your moodledata directory Confirm there is a file with a filename starting with u0_ Run the following command to check the file: cat u0_name_of_the_file Confirm that you can see the content of the file Confirm that the content of the file contains the following information: "url": "http://mockbin.com/request" Cookiejar request Run the cookiejar_test_mockbin.php script using the following command: php cookiejar_test_mockbin,php Confirm that the script ran without any error Confirm that the output contains the following information: {   "cookies": {     "other_cookie": "barbaz1234",      "some_cookie": "foo"   } } Confirm that the output contains the information about the domain: Cookie domain: mockbin.com Continuous requests Run the basictestguzzle_mockbin.php script using the following command: php basictestguzzle_mockbin,php Confirm that the script ran without any error Confirm that all the outputs are available in the console. Calendar test Open calendar/lib.php file. Replace the function calendar_get_icalendar with this function content. Login as admin. Click on User profile menu -> Calendar. Click on Import or export calendars link. Click on Import calendar button. Set the Calendar name to: Test ICS with Guzzle. Set the  Calendar URL to: https://www.officeholidays.com/ics/vietnam Click Import calendar button. Verify that the import process is success. Navigate back to the Calendar. Verify that you will see the new imported events. Remember to revert all the changes for calendar/lib.php file.
    • 10
    • Team Hedgehog Sprint 1.2, Team Hedgehog Sprint 1.3, Team Hedgehog Sprint 1 review, Team Hedgehog Sprint 2.1

    Description

      The Guzzle PHP library (https://docs.guzzlephp.org) is a HTTP client that aims to make it easy to send HTTP requests and integrate with external webservices.

      This issue is to explore to see if this is a good fit for Moodle LMS. Some of the considerations to explore are:

      • Moodle's proxy settings
      • IP allow and block lists
      • Cookie jar
      • caching
      • Composer dependencies
      • Community plugins using Guzzle already

       

      If it is decided to include Guzzle into Moodle LMS, the first step would be to implement it as part of another integration project, so that there is a real world use case for it.

      Replacing the existing curl implementation in Moodle would be a second phase.

       

       

      Attachments

        1. simple_test.php
          0.3 kB
        2. simple_test_mockbin.php
          0.3 kB
        3. simple_test_2.php
          0.3 kB
        4. simple_test_2_mockbin.php
          0.3 kB
        5. Cookiejar request.png
          Cookiejar request.png
          220 kB
        6. cookiejar_test.php
          0.6 kB
        7. cookiejar_test_mockbin.php
          0.6 kB
        8. Continuous request.png
          Continuous request.png
          1.24 MB
        9. calendar Test.gif
          calendar Test.gif
          442 kB
        10. Cache Request.png
          Cache Request.png
          709 kB
        11. cache_test.php
          0.4 kB
        12. cache_test_mockbin.php
          0.4 kB
        13. basictestguzzle.php
          1 kB
        14. basictestguzzle_mockbin.php
          1 kB
        15. Basic Request.png
          Basic Request.png
          375 kB

        Issue Links

          Activity

            People

              safat.shahin@moodle.com Safat Shahin
              matt.porritt@moodle.com Matt Porritt
              Huong Nguyen Huong Nguyen
              Ilya Tregubov Ilya Tregubov
              Ron Carl Alfon Yu Ron Carl Alfon Yu
              Votes:
              2 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Clockify

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