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

Create API letting clients manage links for their placement

    • MOODLE_500_STABLE
    • MDL-85331-main-5
    • Hide

      Setup

      1. Required: Access to the database that the site is installed on
        1. Have the "lti_resource_link" table open and ensure it is empty if it is a fresh install
      2. Create two Moodle sites running on localhost - one designated 'platform', one 'tool'.
      3. In both sites, go to admin settings and clear all values from the 'curlsecurityblockedhosts' admin setting and save.
      4. In the platform site, create a course called "Platform course" and enrol a teacher.
      5. In the tool site, create a course called "Tool course", with:
        • An assignment called "Assign 1" with a max grade of 80.
        • An assignment called "Assign 2" with default settings.
        • A file resource (representing a non-graded activity).
        • A teacher enrolled.
      6. In the tool site admin settings:
        • Enable enrol_lti and auth_lti plugins.
        • Enable "Allow frame embedding".
      7. On the tool site, go to Admin > Plugins > Enrolments > Publish as LTI tool > Tool registration.
      8. Click ‘Register a platform’, enter a name for the platform and click "Continue".
      9. Once the platform is registered, keep this page with the registration details open, we'll need it shortly.
      10. On the platform site, go to 'Admin > General > LTI > Manage tools'.
      11. In the ‘Add tool’ section, paste the dynamic registration URL from the registration details on the tool site and click ‘Add LTI Advantage’.
      12. Once the tool is created click on ‘Activate’.
      13. Now, go to the ‘Platform course’ course and select ‘LTI external tools’ from the secondary navigation.
      14. Enable ‘Show in activity chooser’ for the tool.

      Adding a new LTI module instance

      1. Log out of both the platform and tool sites completely.
      2. In the platform site, login at the teacher.
      3. Go to the "Platform course" course.
      4. Click to add a new activity, selecting the Tool.
      5. When the edit page loads, click the "Select content" button.
      6. Proceed to link your account by clicking the "Link this account" button.
      7. Go to the tool site's course 'Tool course'.
      8. From the menu, select "Published as LTI Tools"
      9. In the "LTI Advantage" tab, click "Add".
      10. Enter the following values:
        • Set "Tool to be published" to "Assign 1".
        • Save.
      11. Repeat steps 9-10 and publish ‘Assign 2’ and the file resource.
      12. Now, go back to the platform site and again, click "Select content".
      13. Click "Select content" again.
      14. Make sure both checkboxes for "Assign 1" are checked this time
      15. Click “Add content”.
      16. Click "Save and return to course"
      17. Verify that the “Assign 1” activity has been successfully added In the “Platform course” course
      18. Verify that the "lti_resource_link" database table now has a record in it containing data from the new LTI instance

      Updating an existing LTI module instance

      1. After confirming the previous test, navigate back to the new LTI instance settings page in the platform site
      2. Change the activity name to a new testing value
      3. Press the "Save and return to course" button
      4. Verify that the "lti_resource_link" record created in the previous test now has an updated value within the "title" field

      Delete a specified LTI module instance

      1. After confirming the previous test, delete the updated mod_lti instance
      2. Verify that the "lti_resource_link" record updated in the previous test has been removed
      Show
      Setup Required: Access to the database that the site is installed on Have the "lti_resource_link" table open and ensure it is empty if it is a fresh install Create two Moodle sites running on localhost - one designated 'platform', one 'tool'. In both sites, go to admin settings and clear all values from the 'curlsecurityblockedhosts' admin setting and save. In the platform site, create a course called "Platform course" and enrol a teacher. In the tool site, create a course called "Tool course", with: An assignment called "Assign 1" with a max grade of 80. An assignment called "Assign 2" with default settings. A file resource (representing a non-graded activity). A teacher enrolled. In the tool site admin settings: Enable enrol_lti and auth_lti plugins. Enable "Allow frame embedding". On the tool site, go to Admin > Plugins > Enrolments > Publish as LTI tool > Tool registration. Click ‘Register a platform’, enter a name for the platform and click "Continue". Once the platform is registered, keep this page with the registration details open, we'll need it shortly. On the platform site, go to 'Admin > General > LTI > Manage tools'. In the ‘Add tool’ section, paste the dynamic registration URL from the registration details on the tool site and click ‘Add LTI Advantage’. Once the tool is created click on ‘Activate’. Now, go to the ‘Platform course’ course and select ‘LTI external tools’ from the secondary navigation. Enable ‘Show in activity chooser’ for the tool. Adding a new LTI module instance Log out of both the platform and tool sites completely. In the platform site, login at the teacher. Go to the "Platform course" course. Click to add a new activity, selecting the Tool. When the edit page loads, click the "Select content" button. Proceed to link your account by clicking the "Link this account" button. Go to the tool site's course 'Tool course'. From the menu, select "Published as LTI Tools" In the "LTI Advantage" tab, click "Add". Enter the following values: Set "Tool to be published" to "Assign 1". Save. Repeat steps 9-10 and publish ‘Assign 2’ and the file resource. Now, go back to the platform site and again, click "Select content". Click "Select content" again. Make sure both checkboxes for "Assign 1" are checked this time Click “Add content”. Click "Save and return to course" Verify that the “Assign 1” activity has been successfully added In the “Platform course” course Verify that the "lti_resource_link" database table now has a record in it containing data from the new LTI instance Updating an existing LTI module instance After confirming the previous test, navigate back to the new LTI instance settings page in the platform site Change the activity name to a new testing value Press the "Save and return to course" button Verify that the "lti_resource_link" record created in the previous test now has an updated value within the "title" field Delete a specified LTI module instance After confirming the previous test, delete the updated mod_lti instance Verify that the "lti_resource_link" record updated in the previous test has been removed
    • Hide

      Fails against automated checks.

      Checked MDL-85331 using repository: https://github.com/mihailges/moodle.git

      Should these errors be fixed?

      Built on: Wed Jun 11 06:05:41 UTC 2025

      Show
      Fails against automated checks. Checked MDL-85331 using repository: https://github.com/mihailges/moodle.git main [branch: MDL-85331-main-5 | CI Job ] Error: The MDL-85331 -main-5 branch at https://github.com/mihailges/moodle.git does not apply clean to origin/main Error: Merge conflict(s) in file(s): Error: lib/db/upgrade.php Error: version.php Should these errors be fixed? Built on: Wed Jun 11 06:05:41 UTC 2025
    • 5
    • Team Alpha - Sprint 1 I2-2025, Team Alpha - Sprint 2 I2-2025

      MDL-84827 ensured that links are created at the point of module instance saving, but using the resource_link persistent directly in client code leaves something to be desired.

      Ideally, I think we want to allow clients to create tools links via their placement type by calling into a core_ltix API that can:

      1. Check the placement type. This should validate it, and make sure it's enabled for the given tool.
      2. Perhaps abstract away some of the internals of the resource link storage (i.e. the itemtype). We know we're going to use the placement type as the itemtype, so using that in naming instead of directly asking for itemtype will be less confusing.

      My feeling is that the bulk of this code probably shouldn't reside in the placements_manager itself, as that class already has a nice neat scope: dealing with creation of placement types, placements and placement config. Of course, that doesn't stop the manager class being being an entry point, but it would probably act as a factory for other objects in that case (similar to the way we currently can ask it for the component's deep linking placement implementation). This just documents some thoughts Mihail and I had when talking about this. We probably want to ask the manager for some sort of placement object (name tbd) and then using that, we manage the links.

      This should also update the mod_lti calling code to use the new API instead of directly using the resource_link persistent as it does currently.

            Geshoski Mihail Geshoski
            jaked Jake Dallimore
            Jake Dallimore Jake Dallimore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

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