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

Create a capability to update H5P content-type libraries

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.8
    • Fix Version/s: 3.8
    • Component/s: H5P
    • Testing Instructions:
      Hide

      Setup

      1. Upload the test-h5p.html file to the $CFG->wwwroot.
      2. Login as admin.
      3. Create a student (s1).
      4. Create a teacher (t1).
      5. Create a course "Course 1".
      6. Access to the course.
      7. Enrol s1 and t1 to the course.
      8. Create a "Forum". Set the "Maximum attachment size" in the "Attachments and word count" section to "Site upload límit".
      9. Send a post to the forum. Add the course-presentation-updated.h5p file as an attachment.
      10. Logout.
      11. Login as t1.
      12. Access to the course.
      13. Reply to the existing post in the forum. Add the course-presentation.h5p file and the arithmetic-quiz.h5p file as attachments.
      14. Logout.
      15. Login as s1.
      16. Access to the course.
      17. Reply to the existing post in the forum. Add the course-presentation-updated.h5p file as an attachment.

       

      Testing scenario 1. Files uploaded by STUDENTS are not displayed

      1. Login as admin.
      2. Go to the "Forum" in the "Course 1" and open the existing post.
      3. Copy the URL for the course-presentation-updated.h5p file uploaded by s1.
      4. Open $CFG->wwwroot/test-h5p.html in a new tab.
      5. Paste the previous URL into the "H5P file URL" form field.
      6. Click the Display button.
      7. Check the following error is displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content."
      8. Logout.
      9. Login as s1.
      10. Reload the H5P page (the one opened in a new tab in step #4).
      11. Check the following error is still displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content."

       

      Testing scenario 2. Files uploaded by TEACHERS are not displayed if the libraries don't exist

      1. Login as admin.
      2. Go to the "Forum" in the "Course 1" and open the existing post.
      3. Copy the URL for the course-presentation.h5p file uploaded by t1.
      4. Open $CFG->wwwroot/test-h5p.html in a new tab.
      5. Paste the previous URL into the "H5P file URL" form field.
      6. Click the Display button.
      7. Check the following errors are displayed:
        • "This file can't be displayed because it has been uploaded by a user without the capability to update H5P content types. Please contact your administrator to ask for the content type to be installed."
        • Several "missing-required-library : Missing required library XXXXX".
      8. Logout.
      9. Login as t1.
      10. Reload the H5P page (the one opened in a new tab in step #4).
      11. Check the following errors are displayed:
        • "Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries. Contact the site administrator about this."
        • Several "missing-required-library : Missing required library XXXXX".

       

      Testing scenario 3. Files uploaded by ADMINS are deployed/displayed

      1. Login as t1.
      2. Go to the "Forum" in the "Course 1" and open the existing post.
      3. Copy the URL for the course-presentation-updated.h5p file uploaded by s1.
      4. Open $CFG->wwwroot/test-h5p.html in a new tab.
      5. Paste the previous URL into the "H5P file URL" form field.
      6. Click the Display button.
      7. Check the following error is displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content."
      8. Come back to the other tab, where the forum is open.
      9. Copy the URL for the course-presentation-updated.h5p file uploaded by admin.
      10. Open $CFG->wwwroot/test-h5p.html in a new tab.
      11. Paste the previous URL into the "H5P file URL" form field.
      12. Click the Display button.
      13. Check the H5P content is displayed and working as expected.

       

      Testing scenario 4. Teachers can deploy files if the libraries exist (even if they are newer than the required)

      1. Login as t1.
      2. Go to the "Forum" in the "Course 1" and open the existing post.
      3. Copy the URL for the course-presentation.h5p file uploaded by t1.
      4. Open $CFG->wwwroot/test-h5p.html in a new tab.
      5. Paste the previous URL into the "H5P file URL" form field.
      6. Click the Display button.
      7. Check the following errors are displayed above the H5P content:
        • The version of the H5P library H5P.Blanks used in this content is not valid. Content contains H5P.Blanks 1.11, but it should be H5P.Blanks 1.12.
        • The version of the H5P library H5P.MultiChoice used in this content is not valid. Content contains H5P.MultiChoice 1.13, but it should be H5P.MultiChoice 1.14.
      8. Check the H5P content is displayed and working as expected.
      9. Reload the page.
      10. Check the H5P content is displayed and working as expected. No error should be displayed now.

       

      Testing scenario 5. Teachers can also update libraries if the capability is assigned

      1. Login as admin.
      2. Go to the "Forum" in the "Course 1" and open the existing post.
      3. Copy the URL for the arithmetic-quiz.h5p file uploaded by t1.
      4. Open $CFG->wwwroot/test-h5p.html in a new tab.
      5. Paste the previous URL into the "H5P file URL" form field.
      6. Click the Display button.
      7. Check the following errors are displayed:
        • "This file can't be displayed because it has been uploaded by a user without the capability to update H5P content types. Please contact your administrator to ask for the content type to be installed."
        • missing-required-library : Missing required library H5P.ArithmeticQuiz 1.1
        • missing-required-library : Missing required library Odometer 1.0
      8. Check the H5P content is NOT displayed.
      9. Come back to the forum tab.
      10. Edit the "Forum" permissions.
      11. Add the "Teacher" to the Roles with permission for the "Allow to update H5P content-type libraries" capability.
      12. Come back to the second tab (the one where the H5P content should be displayed).
      13. Reload the page.
      14. Check the H5P content now is displayed and working as expected.

       

      Show
      Setup Upload the test-h5p.html file to the $CFG->wwwroot. Login as admin. Create a student (s1). Create a teacher (t1). Create a course "Course 1". Access to the course. Enrol s1 and t1 to the course. Create a "Forum". Set the "Maximum attachment size" in the "Attachments and word count" section to "Site upload límit". Send a post to the forum. Add the  course-presentation-updated.h5p  file as an attachment. Logout. Login as t1. Access to the course. Reply to the existing post in the forum. Add the  course-presentation.h5p  file and the arithmetic-quiz.h5p  file as attachments. Logout. Login as s1. Access to the course. Reply to the existing post in the forum. Add the  course-presentation-updated.h5p  file as an attachment.   Testing scenario 1. Files uploaded by STUDENTS are not displayed Login as admin. Go to the "Forum" in the "Course 1" and open the existing post. Copy the URL for the course-presentation-updated.h5p  file uploaded by s1. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the following error is displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content." Logout. Login as s1. Reload the H5P page (the one opened in a new tab in step #4). Check  the following error is still displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content."   Testing scenario 2. Files uploaded by TEACHERS are not displayed if the libraries don't exist Login as admin. Go to the "Forum" in the "Course 1" and open the existing post. Copy the URL for the course-presentation.h5p  file uploaded by t1. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the following errors are displayed: "This file can't be displayed because it has been uploaded by a user without the capability to update H5P content types. Please contact your administrator to ask for the content type to be installed." Several "missing-required-library : Missing required library XXXXX". Logout. Login as t1. Reload the H5P page (the one opened in a new tab in step #4). Check  the following errors are displayed: "Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries. Contact the site administrator about this." Several "missing-required-library : Missing required library XXXXX".   Testing scenario 3. Files uploaded by ADMINS are deployed/displayed Login as t1. Go to the "Forum" in the "Course 1" and open the existing post. Copy the URL for the course-presentation-updated.h5p  file uploaded by s1. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the following error is displayed: "This file can't be displayed because it has been uploaded by a user without the required capability to deploy H5P content." Come back to the other tab, where the forum is open. Copy the URL for the course-presentation-updated.h5p  file uploaded by admin. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the H5P content is displayed and working as expected.   Testing scenario 4. Teachers can deploy files if the libraries exist (even if they are newer than the required) Login as t1. Go to the "Forum" in the "Course 1" and open the existing post. Copy the URL for the course-presentation.h5p  file uploaded by t1. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the following errors are displayed above the H5P content: The version of the H5P library H5P.Blanks used in this content is not valid. Content contains H5P.Blanks 1.11, but it should be H5P.Blanks 1.12. The version of the H5P library H5P.MultiChoice used in this content is not valid. Content contains H5P.MultiChoice 1.13, but it should be H5P.MultiChoice 1.14. Check  the H5P content is displayed and working as expected. Reload the page. Check  the H5P content is displayed and working as expected. No error should be displayed now.   Testing scenario 5. Teachers can also update libraries if the capability is assigned Login as admin. Go to the "Forum" in the "Course 1" and open the existing post. Copy the URL for the arithmetic-quiz.h5p  file uploaded by t1. Open $CFG->wwwroot/test-h5p.html in a new tab. Paste the previous URL into the "H5P file URL" form field. Click the Display button. Check  the following errors are displayed: "This file can't be displayed because it has been uploaded by a user without the capability to update H5P content types. Please contact your administrator to ask for the content type to be installed." missing-required-library : Missing required library H5P.ArithmeticQuiz 1.1 missing-required-library : Missing required library Odometer 1.0 Check  the H5P content is NOT displayed. Come back to the forum tab. Edit the "Forum" permissions. Add the "Teacher" to the Roles with permission for the "Allow to update H5P content-type libraries" capability. Come back to the second tab (the one where the H5P content should be displayed). Reload the page. Check the H5P content now is displayed and working as expected.  
    • Affected Branches:
      MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-67057-master
    • Sprint:
      H5P Sprint Relase 3.8

      Description

      Whilst reviewing the H5P integration (MDL-66609) an issue has been raised to control who can install/update the content-type libraries.

      There are 2 different approaches, one taking the libraries always from the H5P hub (api.h5p.org) or similar and another adding a capability to admin and managers (h5p:uploadlibraries) to let them upload/deploy the libraries in the .h5p file.

      The first looks nicer but, as for now the H5P hub is only returning the latest content-type libraries, we'll go for the second one for now (and will try to go for the first in the future).

      Requirements:

      • Create a new capability: h5p:updatelibraries
      • This capability would be enabled by default for managers and admins, but not for teachers
      • To write/overwrite a new content type library, a user would need the new h5p:updatelibraries capability
      • Users with h5p:deploy capability but without h5p:updatelibraries capability will be able to upload new H5P content that uses existing libraries in the site. In case any of the libraries they are trying to use in the uploaded content is not available, they would get an error asking them to contact their admin to make that library available, because they don't have h5p:updatelibraries permission

        Attachments

        1. arithmetic-quiz.h5p
          731 kB
        2. Confirmed fixed.png
          Confirmed fixed.png
          3.56 MB
        3. course-presentation.h5p
          4.14 MB
        4. course-presentation-updated.h5p
          4.20 MB
        5. test-h5p.html
          0.5 kB

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/19

                  Time Tracking

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