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

Published content updated in-place can result in grade sync error

XMLWordPrintable

    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-76821-401
    • MDL-76821-master
    • Hide

      Prerequisites

      1. You need two Moodle sites (localhost is fine) - one called 'platform' and one called 'tool'
      2. In the tool site admin settings:
        • Enable enrol_lti and auth_lti plugins
        • Enable "Allow frame embedding"
      3. In BOTH sites:
        • Go to "Administration > Security > HTTP security" and clear all values from the 'curlsecurityblockedhosts' admin setting and save. (to permit localhost-to-localhost calls)

      Course setup

      1. Login to the tool site as the admin
      2. Create a course called 'tool course'
      3. Create an assignment in the course
      4. In another tab, login to the platform site as the admin
      5. Create a course called 'platform course'
      6. Enrol users s1 and s2 into the course as students

      LTI 1.3 setup

      1. Login to the tool site as the admin user
      2. Go to Admin > Plugins > Enrolment plugins > Publish as LTI tool > Tool registration
      3. Click to create a new registration
      4. Name the registration "platform site" and continue
      5. You'll see a dynamic registration URL. Click the "Copy to clipboard" icon to copy it
      6. Now, in another browser tab, login as the admin user to the platform site
      7. Go to to Admin > Plugins > Activities > External tool > Manage tools
      8. Paste the URL value into the "Tool URL" field
      9. Click "Add LTI Advantage"
      10. You should see a tool card now. Click "Activate" on it.
      11. Edit the tool (click the cog)
      12. Set:
        • "Name" to "Moodle LTI Advantage"
        • "Tool configuration usage" to "Show in activity chooser and as a preconfigured tool"
      13. Save the form

      LTI 1.1 setup

      1. Login to the tool site and go to the course
      2. From the course navigation, select "Published as LTI tools" (in the 'more' menu)
      3. Switch to the 'legacy' tab
      4. Click to add a new tool
      5. Under "Tool to be published" select the assignment you created earlier
      6. Save
      7. Now, copy the Launch URL and secret from the table.
      8. Switch to the tab with the platform site in it
      9. Go to the course "platform course"
      10. Click to add an activity or resource
      11. Select "External tool"
      12. Set the name to "Legacy resource link"
      13. Paste the tool's Launch URL into the "Tool URL" field
      14. Expand the form fields using "Show more"
      15. Enter 'cat' for the consumer key (this can be anything really, it's not important)
      16. Paste the tool's secret into the "Shared secret" field
      17. Save

      Testing

      1. Login to the platform site as the user s1
      2. Go to the course and click "Legacy resource link" to launch the tool (this should launch into the assignment)
      3. Log out
      4. Do the same for user s2 (login, launch the external tool instance)
      5. Log out
      6. Now, login to the tool site as the admin user
      7. Go to the "tool course"
      8. From the course navigation, select "Published as LTI tools" (in the 'more' menu)
      9. Switch to the 'legacy' tab
      10. Edit the assignment published tool
      11. Change LTI version to LTI Advantage
      12. Save
      13. Logout
      14. Login to the platform site as the user s1
      15. Go to the "platform course"
      16. Try to launch the external tool instance
      17. Verify you see an error saying something like "The resource is not set up for use over legacy LTI"
      18. Logout
      19. Login to the tool site as the admin in one tab
      20. Login to the platform site as the admin
      21. Go to the "platform course"
      22. Click to add an activity or resource
      23. Select "Moodle LTI Advantage"
      24. Click "Select content"
      25. Link the admin account if prompted
      26. Select the assignment you published clicking "Add to course" and leaving "Add to gradebook" ticked (happens automatically)
      27. Click "Add content"
      28. When you're taken back to the activity form:
        • Change the name to "LTI Advantage resource link"
        • Expand "Privacy" and make sure "Accept grades from the tool" is checked
      29. Save
      30. Logout
      31. Login to the platform as the student s1
      32. Go to the "platform course"
      33. Click the "LTI Advantage resource link" activity. This should launch the assignment
      34. Submit something to the assignment
      35. Logout of both the tool and the platform sites
      36. Login to the platform site as the admin user
      37. Go to the "platform course"
      38. Click the "LTI Advantage resource link" activity
      39. Click "View all submissions" in the assignment
      40. scroll down below the submissions, check the box saying "quick grading"
      41. Now, enter a grade '77' for the only student having a submission (the student who launched through the LTI Advantage resource link)
      42. Save the quick grading changes using the button under the table
      43. Leave this tab open and open up a terminal at the webroot of your "tool" site
      44. run:

        php admin/cli/scheduled_task.php --execute="enrol_lti\local\ltiadvantage\task\sync_grades"
        

      45. If you're testing on 4.2 or master, also then run:

        php admin/cli/adhoc_task.php --execute
        

      46. Verify the output contains a grade synchronisation for the grade '0.77'
      47. Verify there are no exceptions / errors shown in the output
      48. If you're testing in 4.2 or master:
        • Open up the database and run the following:

          select count(*) from mdl_task_adhoc;
          

          (you may need to replace the prefix 'mdl_' with whatever your site uses

        • Verify it displays 0, meaning all adhoc tasks have been processed and have succeeded
      49. Back in the browser, go to the platform course gradebook
      50. Verify you see the grade '77' for the student s1 for the activity "LTI Advantage resource link"
      51. Click the "Legacy LTI resource link activity"
      52. Verify you see an error saying something like "The resource is not set up for use over legacy LTI"
      Show
      Prerequisites You need two Moodle sites (localhost is fine) - one called 'platform' and one called 'tool' In the tool site admin settings: Enable enrol_lti and auth_lti plugins Enable "Allow frame embedding" In BOTH sites: Go to "Administration > Security > HTTP security" and clear all values from the 'curlsecurityblockedhosts' admin setting and save. (to permit localhost-to-localhost calls) Course setup Login to the tool site as the admin Create a course called 'tool course' Create an assignment in the course In another tab, login to the platform site as the admin Create a course called 'platform course' Enrol users s1 and s2 into the course as students LTI 1.3 setup Login to the tool site as the admin user Go to Admin > Plugins > Enrolment plugins > Publish as LTI tool > Tool registration Click to create a new registration Name the registration "platform site" and continue You'll see a dynamic registration URL. Click the "Copy to clipboard" icon to copy it Now, in another browser tab, login as the admin user to the platform site Go to to Admin > Plugins > Activities > External tool > Manage tools Paste the URL value into the "Tool URL" field Click "Add LTI Advantage" You should see a tool card now. Click "Activate" on it. Edit the tool (click the cog) Set: "Name" to "Moodle LTI Advantage" "Tool configuration usage" to "Show in activity chooser and as a preconfigured tool" Save the form LTI 1.1 setup Login to the tool site and go to the course From the course navigation, select "Published as LTI tools" (in the 'more' menu) Switch to the 'legacy' tab Click to add a new tool Under "Tool to be published" select the assignment you created earlier Save Now, copy the Launch URL and secret from the table. Switch to the tab with the platform site in it Go to the course "platform course" Click to add an activity or resource Select "External tool" Set the name to "Legacy resource link" Paste the tool's Launch URL into the "Tool URL" field Expand the form fields using "Show more" Enter 'cat' for the consumer key (this can be anything really, it's not important) Paste the tool's secret into the "Shared secret" field Save Testing Login to the platform site as the user s1 Go to the course and click "Legacy resource link" to launch the tool (this should launch into the assignment) Log out Do the same for user s2 (login, launch the external tool instance) Log out Now, login to the tool site as the admin user Go to the "tool course" From the course navigation, select "Published as LTI tools" (in the 'more' menu) Switch to the 'legacy' tab Edit the assignment published tool Change LTI version to LTI Advantage Save Logout Login to the platform site as the user s1 Go to the "platform course" Try to launch the external tool instance Verify you see an error saying something like "The resource is not set up for use over legacy LTI" Logout Login to the tool site as the admin in one tab Login to the platform site as the admin Go to the "platform course" Click to add an activity or resource Select "Moodle LTI Advantage" Click "Select content" Link the admin account if prompted Select the assignment you published clicking "Add to course" and leaving "Add to gradebook" ticked (happens automatically) Click "Add content" When you're taken back to the activity form: Change the name to "LTI Advantage resource link" Expand "Privacy" and make sure "Accept grades from the tool" is checked Save Logout Login to the platform as the student s1 Go to the "platform course" Click the "LTI Advantage resource link" activity. This should launch the assignment Submit something to the assignment Logout of both the tool and the platform sites Login to the platform site as the admin user Go to the "platform course" Click the "LTI Advantage resource link" activity Click "View all submissions" in the assignment scroll down below the submissions, check the box saying "quick grading" Now, enter a grade '77' for the only student having a submission (the student who launched through the LTI Advantage resource link) Save the quick grading changes using the button under the table Leave this tab open and open up a terminal at the webroot of your "tool" site run: php admin/cli/scheduled_task.php --execute="enrol_lti\local\ltiadvantage\task\sync_grades" If you're testing on 4.2 or master, also then run: php admin/cli/adhoc_task.php --execute Verify the output contains a grade synchronisation for the grade '0.77' Verify there are no exceptions / errors shown in the output If you're testing in 4.2 or master: Open up the database and run the following: select count(*) from mdl_task_adhoc; (you may need to replace the prefix 'mdl_' with whatever your site uses Verify it displays 0, meaning all adhoc tasks have been processed and have succeeded Back in the browser, go to the platform course gradebook Verify you see the grade '77' for the student s1 for the activity "LTI Advantage resource link" Click the "Legacy LTI resource link activity" Verify you see an error saying something like "The resource is not set up for use over legacy LTI"
    • 1
    • Team Hedgehog 2023 Sprint 2.2

      Reported here: https://moodle.org/mod/forum/discuss.php?d=442733

      Problem

      If the enrolment method for a 1.1 tool (the "Published as LTI tool" entry containing the various settings, including which activity/course to share) is updated "in-place" (the LTI version is just changed from 1.1/2.0 to 1.3), then it can cause an error during the LTI Advantage grade sync task:

      Scheduled task failed: Publish as LTI tool grade sync (enrol_lti\local\ltiadvantage\task\sync_grades),Argument 3 passed to enrol_lti\local\ltiadvantage\entity\user::create() must be of the type int, null given, called in /var/app/current/moodle/enrol/lti/classes/local/ltiadvantage/repository/user_repository.php on line 58 

      This only happens if the legacy method has attached lti user (enrol_lti_users) and occurs because the repository code assumes the enrol_lti_users table will contain this field if it's attached to a 1.3 tool. That is, it doesn't account for this 'update in place' situation where legacy records (which don't contain the field) are present too.

      Replication steps

      1. Set up two local Moodle sites - one provider, one consumer
      2. Perform all the relevant LTI setup on the provider site (enrol_lti and auth_lti need enabling, allow frame embedding)
      3. Publish an assignment activity on the provider site using legacy (1.1/2.0 method)
      4. In the consumer site, create a course.
      5. Create a new external tool instance in the course, using:
        • Launch URL for the Tool URL
        • Secret for the Shared secret
        • Use 'testconsumer' as the consumer key (this can really be anything)
      6. As a student, launch into the external tool instance (this will create the relevant enrol_lti_users records)
      7. Now, log in to the provider site as the teacher/admin
      8. Go to the published resource (the activity you published over 1.1)
      9. Edit the settings and change the LTI version to 1.3
      10. Save
      11. Now, log out.
      12. Log in to the consumer site as the admin
      13. Perform the relevant LTI 1.3 setup (see https://docs.moodle.org/401/en/Publish_as_LTI_tool#Dynamic_Registration)
      14. Once you've got the preconfigured tool, go to the course
      15. Click to add a new instance of external tool
      16. Select the 1.3 tool now
      17. Click "Select content" when prompted (signing is and linking accounts to the admin/teacher as needed)
      18. Select the published activity
      19. Name the activity "1.3 tool instance" to make it clear.
      20. Save the activity
      21. Log out
      22. Log in as the student
      23. Launch the "1.3 tool instance" tool
      24. Now, log out
      25. Log in as the admin user
      26. Launch the "1.3 tool instance" tool
      27. Click "View all submissions"
      28. Enable quick grading (checkbox below the student rows)
      29. Enter a grade for both student entries (for the student who launched over 1.1 and the student who launched over 1.3). These may be the same student - that's fine.
      30. Save all quick grading changes
      31. Now, in the provider site root, run the grade sync:

        php admin/cli/scheduled_task.php --execute="\enrol_lti\local\ltiadvantage\task\sync_grades"
        

        Expected: Grade sync task runs without error and syncs the grade given to the LTI Advantage user.
        Actual: grade sync error:

        Scheduled task failed: Publish as LTI tool grade sync (enrol_lti\local\ltiadvantage\task\sync_grades),Argument 3 passed to enrol_lti\local\ltiadvantage\entity\user::create() must be of the type int, null given, called in /var/app/current/moodle/enrol/lti/classes/local/ltiadvantage/repository/user_repository.php on line 58 
        

      Solution

      LTI Advantage grade sync should only concern itself with LTI Advantage users, so we can just skip those records which are associated with the legacy enrolment method.

      We also need to consider whether to prohibit this 'in place update' of the enrolment method. I'll admit this wasn't the original intention and was likely an oversight on my part. The intention was to bring up 1.3 tools alongside their 1.1 counterparts to allow users to confirm 1.3 launches work, before disabling access to the 1.1 instance.

      Finally, if we do allow in-place updates, we need to make sure that legacy launches are prevented via the now-updated enrolment instance. Currently, if I update the instance from 1.1 to 1.3 - and provided the 1.1 links are still present in the platform - I can launch into the tool via either 1.1 or 1.3. This shouldn't be possible since we only have a 1.3 instance.

        1. (I) Passed -- (Master)MDL-76821.png
          (I) Passed -- (Master)MDL-76821.png
          87 kB
        2. result_1.png
          result_1.png
          188 kB
        3. result_2.png
          result_2.png
          151 kB

            jaked Jake Dallimore
            jaked Jake Dallimore
            Stevani Andolo Stevani Andolo
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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