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

LTI Tools don't get deleted when linked activity module is deleted from course

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_35_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
    • MDL-68843-311
    • MDL-68843-400
    • MDL-68843-master
    • Hide

      Upgrade test

      1. Create a new site, checking out the latest weekly - don't install yet.
        Master:

        git checkout ac9e395e
        

        400:

        git checkout 4a9fa426
        

        311:

        git checkout 22dffcd0
        

      2. Install the site
      3. Log in as site admin and enable the following plugins:
        • enrol_lti (Site admin > Plugins > Enrolments > Manage enrol plugins)
        • auth_lti (Site admin > Plugins > Authentication > Manage authentication)
      4. Create a course
      5. Create two assignments in the course
        • Assignment 1
        • Assignment 2
        • Assignment 3
      6. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      7. Now, we need to publish the assignments. This varies depending on Moodle version:
        • For 400 and master
          • Select the LTI Advantage tab
          • Click add
          • Set 'Tool to be published' to Assignment 1
          • Save
          • Select the LTI Advantage tab
          • Click add
          • Set 'Tool to be published' to Assignment 2
          • Set 'Custom instance name' to "Custom assign 2 instance"
          • Save
          • Select the LTI Advantage tab
          • Click add
          • Set 'Tool to be published' to Assignment 3
          • Save
          • Verify you now have 3 shared activities under the LTI Advantage tab.
          • Repeat the process using the "Legacy LTI" tab.
          • Verify you now also have 3 shared activities under the Legacy LTI tab.
        • For 311
          • Click add
          • Set 'Tool to be published' to Assignment 1
          • Save
          • Click add
          • Set 'Tool to be published' to Assignment 2
          • Set 'Custom instance name' to "Custom assign 2 instance"
          • Save
          • Click add
          • Set 'Tool to be published' to Assignment 3
          • Save
          • Verify you now have 3 shared activities
      8. Now, go to the course home
      9. Delete the activity "Assignment 1"
      10. Delete the activity "Assignment 2"
      11. Run cron for the site via the terminal:

        php admin/cli/cron.php
        

      12. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      13. Verify you see an error
      14. Now, checkout the current changes
        Master:

        git checkout master
        

        400:

        git checkout MOODLE_400_STABLE
        

        311:

        git checkout MOODLE_311_STABLE
        

      15. Run the site upgrade
      16. When the upgrade is complete, go to the course.
      17. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      18. Now, we'll verify the published activities have been updated accordingly. This varies depending on Moodle version:
        • For 400 and master
          • Go to the LTI Advantage tab
          • Verify you see a "Deleted activity" notice in the name column of the first instance
          • Verify the first instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Verify you see a "Deleted activity" notice along with "Custom assign to instance" in the name column of the second instance
          • Verify the second instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Verify you see "Assignment: Assignment 3" in the name column of the third instance
          • Verify the third instance is still enabled
          • Repeat the process for the Legacy LTI tab
        • For 311
          • Verify you see a "Deleted activity" notice in the name column of the first instance
          • Verify the first instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Verify you see a "Deleted activity" notice along with "Custom assign to instance" in the name column of the second instance
          • Verify the second instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Verify you see "Assignment: Assignment 3" in the name column of the third instance
          • Verify the third instance is still enabled

      Activity deletion test

      Note: This test follows on from the test steps above

      1. Go to the course.
      2. Delete activity "Assignment 3"
      3. Run cron for the site via the terminal:

        php admin/cli/cron.php
        

      4. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      5. Now, we'll verify the published activities have been updated accordingly. This varies depending on Moodle version:
        • For 400 and master
          • Go to the LTI Advantage tab
          • Verify you see a "Deleted activity" notice in the name column of the third instance
          • Verify the third instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Click edit and Verify you're taken to the edit instance form, with no errors.
          • Select a new activity from the list under "Tool to be published" (or select 'Course')
          • Save
          • Verify you now see the instance listed in the table without the warning notice but that it is still disabled
          • Enable the method and confirm no errors
          • Verify you now see the instance listed in the table without the warning notice and that is is also now enabled.
          • Repeat the process for the "Legacy LTI" tab
        • For 311
          • Verify you see a "Deleted activity" notice in the name column of the third instance
          • Verify the third instance is disabled
          • Click the exclamation icon and Verify you see some help text in a popover
          • Click edit and Verify you're taken to the edit instance form, with no errors.
          • Select a new activity from the list under "Tool to be published" (or select 'Course')
          • Save
          • Verify you now see the instance listed in the table without the warning notice but that it is still disabled
          • Enable the method and confirm no errors
          • Verify you now see the instance listed in the table without the warning notice and that is is also now enabled.
      Show
      Upgrade test Create a new site, checking out the latest weekly - don't install yet. Master: git checkout ac9e395e 400: git checkout 4a9fa426 311: git checkout 22dffcd0 Install the site Log in as site admin and enable the following plugins: enrol_lti (Site admin > Plugins > Enrolments > Manage enrol plugins) auth_lti (Site admin > Plugins > Authentication > Manage authentication) Create a course Create two assignments in the course Assignment 1 Assignment 2 Assignment 3 From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools Now, we need to publish the assignments. This varies depending on Moodle version: For 400 and master Select the LTI Advantage tab Click add Set 'Tool to be published' to Assignment 1 Save Select the LTI Advantage tab Click add Set 'Tool to be published' to Assignment 2 Set 'Custom instance name' to "Custom assign 2 instance" Save Select the LTI Advantage tab Click add Set 'Tool to be published' to Assignment 3 Save Verify you now have 3 shared activities under the LTI Advantage tab. Repeat the process using the "Legacy LTI" tab. Verify you now also have 3 shared activities under the Legacy LTI tab. For 311 Click add Set 'Tool to be published' to Assignment 1 Save Click add Set 'Tool to be published' to Assignment 2 Set 'Custom instance name' to "Custom assign 2 instance" Save Click add Set 'Tool to be published' to Assignment 3 Save Verify you now have 3 shared activities Now, go to the course home Delete the activity "Assignment 1" Delete the activity "Assignment 2" Run cron for the site via the terminal: php admin/cli/cron.php From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools Verify you see an error Now, checkout the current changes Master: git checkout master 400: git checkout MOODLE_400_STABLE 311: git checkout MOODLE_311_STABLE Run the site upgrade When the upgrade is complete, go to the course. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools Now, we'll verify the published activities have been updated accordingly. This varies depending on Moodle version: For 400 and master Go to the LTI Advantage tab Verify you see a "Deleted activity" notice in the name column of the first instance Verify the first instance is disabled Click the exclamation icon and Verify you see some help text in a popover Verify you see a "Deleted activity" notice along with "Custom assign to instance" in the name column of the second instance Verify the second instance is disabled Click the exclamation icon and Verify you see some help text in a popover Verify you see "Assignment: Assignment 3" in the name column of the third instance Verify the third instance is still enabled Repeat the process for the Legacy LTI tab For 311 Verify you see a "Deleted activity" notice in the name column of the first instance Verify the first instance is disabled Click the exclamation icon and Verify you see some help text in a popover Verify you see a "Deleted activity" notice along with "Custom assign to instance" in the name column of the second instance Verify the second instance is disabled Click the exclamation icon and Verify you see some help text in a popover Verify you see "Assignment: Assignment 3" in the name column of the third instance Verify the third instance is still enabled Activity deletion test Note: This test follows on from the test steps above Go to the course. Delete activity "Assignment 3" Run cron for the site via the terminal: php admin/cli/cron.php From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools Now, we'll verify the published activities have been updated accordingly. This varies depending on Moodle version: For 400 and master Go to the LTI Advantage tab Verify you see a "Deleted activity" notice in the name column of the third instance Verify the third instance is disabled Click the exclamation icon and Verify you see some help text in a popover Click edit and Verify you're taken to the edit instance form, with no errors. Select a new activity from the list under "Tool to be published" (or select 'Course') Save Verify you now see the instance listed in the table without the warning notice but that it is still disabled Enable the method and confirm no errors Verify you now see the instance listed in the table without the warning notice and that is is also now enabled. Repeat the process for the "Legacy LTI" tab For 311 Verify you see a "Deleted activity" notice in the name column of the third instance Verify the third instance is disabled Click the exclamation icon and Verify you see some help text in a popover Click edit and Verify you're taken to the edit instance form, with no errors. Select a new activity from the list under "Tool to be published" (or select 'Course') Save Verify you now see the instance listed in the table without the warning notice but that it is still disabled Enable the method and confirm no errors Verify you now see the instance listed in the table without the warning notice and that is is also now enabled.

    Description

      When a tool is published within a course, if the associated tool is removed from the course, the "Published as LTI Tools" menu will end up inaccessible due to an "Can't find data record in database table context." exception.

      It seems like the adhoc task that deletes the course modules leaves an inconsistency in the database. In the "enrol_lti_tools" table it remains the row pointing to a context that no longer exists. This can be detected with a simple query:

      Steps to replicate:

      1. Enable LTI authentication and LTI enrol method in your site.
      2. Create a quiz activity module in a course.
      3. Go in this same course to the "Published as LTI Tools" menu and add this quiz as a published tool.
      4. Go back to the course and delete the quiz.
      5. Wait until the adhoc task "course_delete_modules" runs and completely removes the activity module.
      6. Check the "Published as LTI Tools" menu, you should see a "Can't find data record in database table context." exception.

      SELECT elt.*
      FROM mdl_enrol_lti_tools elt
      WHERE elt.contextid NOT IN (SELECT ctx.id FROM mdl_context ctx)

      There should be a handler observing the \core\event\course_module_deleted event in order to delete the shared tool as soon as a tool is removed within the course.

      It could be handled directly in the course_delete_module function in /course/lib.php as well.

      For posterity, the original branch which was attached here is below:
      Repo: https://github.com/Royerino/moodle
      Branch: MDL-68843-master
      Diff: https://github.com/moodle/moodle/compare/master...Royerino:MDL-68843-master

       

      Attachments

        Activity

          People

            jaked Jake Dallimore
            Royer Yerai Rodríguez
            Neill Magill Neill Magill
            Ilya Tregubov Ilya Tregubov
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 6 minutes
                1d 1h 6m