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

    • Testing Instructions:
      Hide

      In order to verify the fix is correct:

      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 NOT see the shared tool you previously created.
      Show
      In order to verify the fix is correct: Enable LTI authentication and LTI enrol method in your site. Create a quiz activity module in a course. Go in this same course to the "Published as LTI Tools" menu and add this quiz as a published tool. Go back to the course and delete the quiz. Wait until the adhoc task "course_delete_modules" runs and completely removes the activity module. Check  the "Published as LTI Tools" menu, you should NOT see the shared tool you previously created.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_35_STABLE, MOODLE_38_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull 3.8 Branch:
    • Pull Master Branch:
      MDL-68843-master

      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.

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            Royer Yerai Rodríguez
            Peer reviewer:
            Neill Magill
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: