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

MoodleNet API changes to file storage and serving

XMLWordPrintable

    • MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-77958-master
    • Hide

      Setup

      1. Navigate to https://mn3.prototype.moodle.net
      2. Create an account if you do not have one already
        1. NOTE: You may need to check your spam folder for the confirmation message

      Manual test:

      1. Create a new Course.
      2. Create a new Assignment activity inside the created Course. Set the description to "Hello world".
      3. Navigate to Site Administration / Development / Experimental settings.
      4. Turn on (Checked) Enable sharing to MoodleNet (outbound).
      5. Save changes.
      6. Navigate to Site Administration / Server / OAuth 2 services.
      7. Click on the MoodleNet button.
      8. Change the URL to "https://mn3.prototype.moodle.net" (so that it points to the MoodleNet prototype site).
      9. Change the name to "Prototype MoodleNet"
      10. Click Save changes.
      11. Navigate to Site Administration / General / MoodleNet outbound settings.
      12. Change the OAuth 2 service to "Prototype MoodleNet"  and save the changes.
      13. Navigate to the the assignment activity you previously created.
      14. Click on the More menu and select Share to MoodleNet.
      15. Click on the Share button.
        1. Verify that a new popup will be open and ask you to authorize with the MoodleNet site.
      16. Click Authorize.
        1. Verify that the popup is closed and the dialogue in the modal within Moodle LMS shows that the system is packaging the activity.
        2. Verify that you will see a successful dialogue say that:  Saved to MoodleNet drafts.
      17. Click the "Go to MoodleNet drafts" button at the bottom right of the modal.
        1. Verify that a new tab opens, which loads the MoodleNet prototype site.
        2. Verify that there is a heading which matches the name of the assignment.
        3. Verify that you seen an attachment with name ending in assign_backup.mbz.
        4. Verify that at the bottom of the information, you see "Hello world" (the activity's description).
      18. Download the file from MoodleNet
      19. Rename the file to backup.tgz
      20. Extract the file:

        cd `mktemp -d`
        tar -zxf path/to/backup.tgz
        

        1. Verify you can extract the file
        2. Verify the extracted file contains:
          1. activities/assign_XXXXX/assign.xml
      Show
      Setup Navigate to https://mn3.prototype.moodle.net Create an account if you do not have one already NOTE: You may need to check your spam folder for the confirmation message Manual test: Create a new Course. Create a new Assignment activity inside the created Course. Set the description to "Hello world". Navigate to Site Administration / Development / Experimental settings. Turn on (Checked) Enable sharing to MoodleNet (outbound). Save changes. Navigate to Site Administration / Server / OAuth 2 services. Click on the MoodleNet button. Change the URL to "https://mn3.prototype.moodle.net" (so that it points to the MoodleNet prototype site). Change the name to "Prototype MoodleNet" Click Save changes. Navigate to Site Administration / General / MoodleNet outbound settings. Change the OAuth 2 service to "Prototype MoodleNet"  and save the changes. Navigate to the the assignment activity you previously created. Click on the More menu and select Share to MoodleNet. Click on the Share button. Verify that a new popup will be open and ask you to authorize with the MoodleNet site. Click Authorize. Verify that the popup is closed and the dialogue in the modal within Moodle LMS shows that the system is packaging the activity. Verify that you will see a successful dialogue say that:  Saved to MoodleNet drafts. Click the "Go to MoodleNet drafts" button at the bottom right of the modal. Verify that a new tab opens, which loads the MoodleNet prototype site. Verify that there is a heading which matches the name of the assignment. Verify that you seen an attachment with name ending in assign_backup.mbz. Verify that at the bottom of the information, you see "Hello world" (the activity's description). Download the file from MoodleNet Rename the file to backup.tgz Extract the file: cd `mktemp -d` tar -zxf path/to/backup.tgz Verify you can extract the file Verify the extracted file contains: activities/assign_XXXXX/assign.xml

      I'm just taking a look at the Moodlenet API, and I have to say I think we need to make some improvements before release. Nothing major, but stuff that should not have even passed PR.

      moodlenet_client

      create_resource_from_file

      1. missing type hints for description
      2. missing return type decs
      3. This should 100% NOT take an array of $filedata. Why do we think it needs to?
        This should just take a single stored_file param:

        public function create_resource_from_stored_file(
            stored_file $file,
            string $resourcename,
            string $resourcedescription,
        ): ResponseInterface;
        

      4. The prepare_file_share_request_data has the same problem.
      5. As do all of the API calls leading up to this. The whole file preparation is wrong.
        We should try really hard not to store file content in memory. So:
        1. activity_packager::package should just return a stored_file.
        2. etc.
      6. We should then make prepare_file_share_request_data take a a filename, mimetype, and important a psr7 StreamInterface
      7. This means that we can stream the file straight from the filesystem without ever loading it into memory at all.
        This is mega important for performance!!
        To do so we need to introduce a new method to:
        1. stored_file
        2. file_system

      I'd consider this a must fix because this is a part of the public API which will be hard to change.

        1. MDL-77958.png
          309 kB
          Ron Carl Alfon Yu

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Michael Hawkins Michael Hawkins
            Jake Dallimore Jake Dallimore
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 59 minutes
                3h 59m

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