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

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_35_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • 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 three assignments in the course
        • Assignment 1
        • Assignment 2
        • Assignment 3
      5. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      6. 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
      7. Now, go to the course home
      8. Delete the activity "Assignment 1"
      9. Delete the activity "Assignment 2"
      10. Run cron for the site via the terminal:

        php admin/cli/cron.php
        

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

        git checkout master
        

        400:

        git checkout MOODLE_400_STABLE
        

        311:

        git checkout MOODLE_311_STABLE
        

      14. Run the site upgrade
      15. When the upgrade is complete, go to the course.
      16. From the course navigation (either the cog menu, or the more menu, depending on version), select Published as LTI tools
      17. 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 (eye icon is crossed)
          • 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 three 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 (eye icon is crossed) 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.

      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

       

        1. deleted_activity_notice.png
          deleted_activity_notice.png
          58 kB
        2. lti_exception.png
          lti_exception.png
          55 kB
        3. MDL-68843_v311_activity deletion.webm
          720 kB
        4. MDL-68843_v311_upgrade_1.png
          MDL-68843_v311_upgrade_1.png
          133 kB
        5. MDL-68843_v311_upgrade_2.png
          MDL-68843_v311_upgrade_2.png
          60 kB
        6. MDL-68843_v311_upgrade_3.webm
          207 kB
        7. MDL-73806_master_activity deletion.webm
          991 kB
        8. MDL-73806_master_upgrade_1.webm
          272 kB
        9. MDL-73806_master_upgrade_2.webm
          109 kB
        10. MDL-73806_master_upgrade_3.webm
          566 kB
        11. MDL-73806_upgrade_2.png
          MDL-73806_upgrade_2.png
          60 kB
        12. MDL-73806_v400_activity deletion.webm
          1.10 MB
        13. MDL-73806_v400_upgrade_1.webm
          251 kB
        14. MDL-73806_v400_upgrade_3.webm
          469 kB

            jaked Jake Dallimore
            Royer Yerai Rodríguez
            Neill Magill Neill Magill
            Ilya Tregubov Ilya Tregubov
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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