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

Course with H5P element in content bank can not be deleted by Manager/Teacher role (with appropriate rights)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      This tests are to check the original issue is solved:

      1. Login as a course creator or manager
      2. Create a course
      3. Add h5p content to course content bank
      4. Delete the course
      5. Ensure course has been deleted and no exception is thrown

      This tests are copied from MDL-67082 to ensure we not breaking module accessibility:

      Setup

      1. Login as admin.
      2. Access to "Site administration / Plugins / Filters / Manage filters".
      3. Disable (set Active? field to "Disabled") the "Display H5P " filter.

      Testing scenario 1. Context Course - Course section

      1. Login as admin.
      2. Go to the "Course 1".
      3. Edit one of the sections.
      4. In that section, upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor.
      5. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded.
      6. Save the changes.
      7. Copy the URL of the h5p file.
      8. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7.

        http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE
        

      9. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in)
      10. Go to your previous browser or tab where you are logged as admin.
      11. And paste the URL in the step 8.
      12. Expected result: Check that you are able to view the H5P file.

      Testing scenario 2. Context Block - Block HTML

      1. Login as admin.
      2. Go to the "Course 1".
      3. Add Block HTML to the course.
      4. Edit the new Block HTML and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor.
      5. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded.
      6. Save the changes.
      7. Copy the URL of the h5p file.
      8. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7.

        http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE

      9. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in)
      10. Go to your previous browser or tab where you are logged as admin.
      11. And paste the URL in the step 8.
      12. Expected result: Check that you are able to view the H5P file.
      13. Now, go to the Dashboard.
      14. Add Block HTML to the Dashboard.
      15. Edit the new Block HTML and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor.
      16. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded.
      17. Save the changes.
      18. Copy the URL of the h5p file.
      19. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7.

        http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE

      20. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Sorry, the requested file could not be found
      21. Go to your previous browser or tab where you are logged as admin.
      22. And paste the URL in the step 19.
      23. Expected result: Check that you are able to view the H5P file.
      24. Login as s1
      25. And paste the URL in the step 19.
      26. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Sorry, the requested file could not be found

      Testing scenario 3. Context Module without get_path_from_pluginfile function implemented.

      1. Login as admin.
      2. Go to the "Course 1".
      3. Add a new activity chat,
      4. Edit the description of the new activity chat and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor.
      5. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded.
      6. Save the changes.
      7. Copy the URL of the h5p file.
      8. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7.

        http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE

      9. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in)
      10. Go to your previous browser or tab where you are logged as admin.
      11. And paste the URL in the step 8.
      12. Expected result: Check that you are able to view the H5P file.

      Testing scenario 4. Context CourseCat

      1. Login as admin.
      2. Go to the course index page: http:/YOURMODDLESITE/course/
      3. Click on Miscellanious category.
      4. Edit the category and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. If you don't see the Editor, be sure that the format option is HTML.
      5. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded.
      6. Save the changes. Then you have to go again over the steps 2 and 3 to see the URL of the h5p file. Also, you could go direct using the url http://yourmoodlesite/course/index.php?categoryid=1
      7. Copy the URL of the h5p file.
      8. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7.

        http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE

      9. Expected result: Check that you are able to view the H5P file.
      10. Go to your previous browser or tab where you are logged as admin.
      11. Go to Site Administration > Security > Site security settings.
      12. Check the option "Force users to log in" (forcelogin).
      13. In a new browser where you aren't authenticated or in incognito mode, paste the same URL in the step 8.
      14. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in)
      15. Go to your previous browser or tab where you are logged as admin.
      16. And paste the URL in the step 8.
      17. Expected result: Check that you are able to view the H5P file.
      Show
      This tests are to check the original issue is solved: Login as a course creator or manager Create a course Add h5p content to course content bank Delete the course Ensure course has been deleted and no exception is thrown This tests are copied from MDL-67082 to ensure we not breaking module accessibility: Setup Login as admin. Access to "Site administration / Plugins / Filters / Manage filters". Disable (set Active? field to "Disabled") the "Display H5P " filter. Testing scenario 1. Context Course - Course section Login as admin. Go to the "Course 1". Edit one of the sections. In that section, upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded. Save the changes. Copy the URL of the h5p file. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7. http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in) Go to your previous browser or tab where you are logged as admin. And paste the URL in the step 8. Expected result: Check that you are able to view the H5P file. Testing scenario 2. Context Block - Block HTML Login as admin. Go to the "Course 1". Add Block HTML to the course. Edit the new Block HTML and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded. Save the changes. Copy the URL of the h5p file. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7. http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Course or activity not accessible. (You are not logged in) Go to your previous browser or tab where you are logged as admin. And paste the URL in the step 8. Expected result: Check that you are able to view the H5P file. Now, go to the Dashboard. Add Block HTML to the Dashboard. Edit the new Block HTML and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded. Save the changes. Copy the URL of the h5p file. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7. http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Sorry, the requested file could not be found Go to your previous browser or tab where you are logged as admin. And paste the URL in the step 19. Expected result: Check that you are able to view the H5P file. Login as s1 And paste the URL in the step 19. Expected result: Check that you are not able to view the H5P without being authenticated. And you see this message: Sorry, the requested file could not be found Testing scenario 3. Context Module without get_path_from_pluginfile function implemented. Login as admin. Go to the "Course 1". Add a new activity chat, Edit the description of the new activity chat and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded. Save the changes. Copy the URL of the h5p file. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7. http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE Expected result:  Check that you are not able to view the H5P without being authenticated. And you see this message:  Course or activity not accessible. (You are not logged in) Go to your previous browser or tab where you are logged as admin. And paste the URL in the step 8. Expected result:  Check that you are able to view the H5P file. Testing scenario 4. Context CourseCat Login as admin. Go to the course index page: http:/YOURMODDLESITE/course/ Click on Miscellanious category. Edit the category and upload an H5P file attached in the issue arithmetic-quiz.h5p using the "Manage files" button in the Atto editor. If you don't see the Editor, be sure that the format option is HTML. Now click the "Link" button, click "Browse repositories", select "Embedded files" and select the h5p file you just uploaded. Save the changes. Then you have to go again over the steps 2 and 3 to see the URL of the h5p file. Also, you could go direct using the url http://yourmoodlesite/course/index.php?categoryid=1 Copy the URL of the h5p file. In a new browser where you aren't authenticated or in incognito mode, paste the next URL and change YOURURLH5PFILE for the url copied in step 7. http://YOURMOODLESITE/h5p/embed.php?url=YOURURLH5PFILE Expected result:  Check that you are able to view the H5P file. Go to your previous browser or tab where you are logged as admin. Go to Site Administration > Security > Site security settings. Check the option " Force users to log in " (forcelogin). In a new browser where you aren't authenticated or in incognito mode, paste the same URL in the step 8. Expected result:  Check that you are not able to view the H5P without being authenticated. And you see this message:  Course or activity not accessible. (You are not logged in) Go to your previous browser or tab where you are logged as admin. And paste the URL in the step 8. Expected result:  Check that you are able to view the H5P file.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull 3.9 Branch:
    • Pull 3.10 Branch:
      MDL-70009-310
    • Pull 3.11 Branch:
      MDL-70009-311
    • Pull Master Branch:
      MDL-70009-master
    • Sprint:
      Moppies Kanban

      Description

      1. Log in as teacher (with rights to delete course and contentbank content) or manager role.

      2. Create a course and add at least one H5P element to the content bank

      3. Try to delete course :

      Moodle deletes most of the course elements but then throws following error :

      Coding error detected, it must be fixed by a programmer: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course.More information about this error

      Debug info: Stack trace when the theme was set up: <ul style="text-align: left" data-rel="backtrace"><li>line 1944 of /lib/setuplib.php: call to moodle_page->initialise_theme_and_output()</li><li>line 65 of /course/deletebyteacher.php: call to bootstrap_renderer->__call()</li></ul>
      Error code: codingerror

      Stack trace:
      line 1921 of /lib/pagelib.php: coding_exception thrown
      line 1011 of /lib/pagelib.php: call to moodle_page->ensure_theme_not_set()
      line 3046 of /lib/moodlelib.php: call to moodle_page->set_course()
      line 3169 of /lib/moodlelib.php: call to require_login()
      line 436 of /h5p/classes/api.php: call to require_course_login()
      line 197 of /h5p/classes/api.php: call to core_h5p\api::get_pluginfile_hash()
      line 341 of /h5p/classes/api.php: call to core_h5p\api::get_content_from_pluginfile_url()
      line 53 of /contentbank/contenttype/h5p/classes/contenttype.php: call to core_h5p\api::delete_content_from_pluginfile_url()
      line 271 of /contentbank/classes/contentbank.php: call to contenttype_h5p\contenttype->delete_content()
      line 5349 of /lib/moodlelib.php: call to core_contentbank\contentbank->delete_contents()
      line 5151 of /lib/moodlelib.php: call to remove_course_contents()
      line 70 of /course/deletebyteacher.php: call to delete_course()

      (Note the /course/deletebyteacher.php file called here, is just a copy of the delete.php file)

       

      Without H5P content in the content bank, Teacher (with appropriate rights) or manager can delete the course without problem.

      With administrator role, the course and the content bank with H5P elements can also be deleted.

      But to be able to delete a course with H5P elements in the content bank, as teacher (with appropriate rights) or manager, every H5P element has to be removed manually first.

      (The moodle site is running with Fordson theme).

        

      It seems to me this is a bug. Has anybody an idea on how to solve this ?

        Attachments

        1. MDL-70009 (3).jpg
          MDL-70009 (3).jpg
          22 kB
        2. MDL-70009 (2).jpg
          MDL-70009 (2).jpg
          56 kB
        3. MDL-70009.jpg
          MDL-70009.jpg
          41 kB
        4. arithmetic-quiz.h5p
          762 kB

          Activity

            People

            Assignee:
            ilyatregubov Ilya Tregubov
            Reporter:
            jakobschlupmann Jakob Schlupmann
            Peer reviewer:
            Ferran Recio
            Integrator:
            Sara Arjona (@sarjona)
            Tester:
            Anna Carissa Sadia
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Jan/21

                Time Tracking

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