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

task \enrol_lti\local\ltiadvantage\task\sync_members ALWAYS updates each user twice for each tool they are enrolled to

XMLWordPrintable

    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-76842-401
    • MDL-76842-402
    • MDL-76842-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, s2 and s3 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
      14. Log out of the platform site

      Publish an activity and set up the resource link in the platform

      1. Login to the tool site as the admin user
      2. Go to the course
      3. From the course nav, select "More > Published as LTI tools"
      4. Click to publish a new resource
      5. Select the assignment in the "Tool to be published" field, leaving everything else alone
      6. Save
      7. Logout
      8. Login to the platform site in the new tab
      9. Go to the course
      10. Click to create an activity or resource
      11. Select the "Moodle LTI Advantage" activity tile
      12. When you're taken to the edit form, click "Select content"
      13. Click to bind your account with the admin account in the tool
      14. When you see the list of activities, select the assignment's "Add to course" (add to gradebook will be auto checked and that's ok)
      15. Click "Add content"
      16. When the modal closes, check the "Privacy" section of the form
      17. Make sure that all options are checked (accept grades, share names, share email). If they aren't checked already, check them now.
      18. Save the activity instance
      19. Log out of the platform site
      20. Log out of the tool site now too - you'll have an existing session but you can trigger logout by visiting SITE/login/ - click Log out when prompted.

      Testing launch-based updates to the user

      1. Now login the the platform site as the student s1
      2. Go to the course but don't do anything yet. Leave this window open
      3. Now, open a new private browsing session (so we can login there and not impact our sessions here)
      4. In the private window, login to the tool site as the admin user
      5. Go to "Site admin >  Reports > Logs". Wait here for now
      6. Switch back to the other window with the platform site and the student
      7. Click the activity name to launch the external tool
      8. When the assignment loads, stop.
      9. Switch back to the private window (admin user in the tool)
      10. Click "Get these logs" to generate all the logs
      11. Near the top of the list, Verify you see the following log entries corresponding to a user id which IS NOT the admin user (i.e. is NOT 2).
        • "User created"
        • "User has logged in"
        • "User enrolled in course"
        • "Role assigned"
        • "Course module viewed"
      12. Verify you don't see a log entry for that same user which reads "User updated"
      13. Now, switch back to the window with the student
      14. Relaunch the tool (refresh the page)
      15. Go back to the other window (admin user in the tool site) and click the "Get these logs" button again
      16. Verify that you now see the following logs:
        • "User has logged in"
        • "Course module viewed"
      17. Switch back to the other window with the platform student
      18. Edit your profile, changing your surname
      19. Save the change
      20. Go to the course
      21. Launch the tool once again
      22. Now switch back to the other window (tool site, admin user)
      23. Click "Get these logs" again
      24. Verify you now see (again near the top) the following:
        • "User updated"
        • "User has logged in"
        • "Course module viewed"
      25. Switch back to the other window with the platform student
      26. Launch the tool once again (or refresh)
        Now switch back to the other window (tool site, admin user)
      27. Click "Get these logs" again
      28. Verify you now see (again near the top) the following:
        • "User has logged in"
        • "Course module viewed"
      29. Verify you don't see "User updated" among the above group of logs
      30. Now, continuing in the tool site window, go to the 'tool course'
      31. Go to "More > Published as LTI tools" in the course navigation
      32. Edit the published resource
      33. Expand "User default values"
      34. Set "Institution" to "My institution"
      35. Save the form
      36. Now go back to "Site admin > Reports >Logs" and wait there
      37. Switch back to the other window with the platform student
      38. Relaunch the tool again (or refresh the page)
      39. Switch back to the window with the tool site, admin user
      40. Click "Get these logs" once again
      41. Verify you now see (again near the top) the following:
        • "User updated"
        • "User has logged in"
        • "Course module viewed"
      42. Keep this page open for the next section of testing

      Testing names and roles sync-based updates to the user

      1. Open up a terminal in the web root of your tool site
      2. Run the following to sync members from the platform site:

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

      3. Verify you see the following log entries near the top of the results:
        • "User created"
        • "User updated" (we expect to see the updated log here because the user's institution, per the tool defaults, will have been updated to "My institution")
        • "User enrolled in course"
      4. Verify you see these logs for 2 distinct users (check the description 'column')
      5. Now, run the same task again:

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

      6. Go back to the logs page and click "Get these logs" again
      7. Verify that you don't see any "User created" or "User updated" logs for the recent run of the task (you can check the times of the log entries to correlate these)
      8. Click the name of one of the user who was created and then updated.
      9. Edit their profile
      10. Expand "Optional"
      11. Verify that under "Institution" you see "My institution"
      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, s2 and s3 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 Log out of the platform site Publish an activity and set up the resource link in the platform Login to the tool site as the admin user Go to the course From the course nav, select "More > Published as LTI tools" Click to publish a new resource Select the assignment in the "Tool to be published" field, leaving everything else alone Save Logout Login to the platform site in the new tab Go to the course Click to create an activity or resource Select the "Moodle LTI Advantage" activity tile When you're taken to the edit form, click "Select content" Click to bind your account with the admin account in the tool When you see the list of activities, select the assignment's "Add to course" (add to gradebook will be auto checked and that's ok) Click "Add content" When the modal closes, check the "Privacy" section of the form Make sure that all options are checked (accept grades, share names, share email). If they aren't checked already, check them now. Save the activity instance Log out of the platform site Log out of the tool site now too - you'll have an existing session but you can trigger logout by visiting SITE/login/ - click Log out when prompted. Testing launch-based updates to the user Now login the the platform site as the student s1 Go to the course but don't do anything yet. Leave this window open Now, open a new private browsing session (so we can login there and not impact our sessions here) In the private window, login to the tool site as the admin user Go to "Site admin >  Reports > Logs". Wait here for now Switch back to the other window with the platform site and the student Click the activity name to launch the external tool When the assignment loads, stop. Switch back to the private window (admin user in the tool) Click "Get these logs" to generate all the logs Near the top of the list, Verify you see the following log entries corresponding to a user id which IS NOT the admin user (i.e. is NOT 2). "User created" "User has logged in" "User enrolled in course" "Role assigned" "Course module viewed" Verify you don't see a log entry for that same user which reads "User updated" Now, switch back to the window with the student Relaunch the tool (refresh the page) Go back to the other window (admin user in the tool site) and click the "Get these logs" button again Verify that you now see the following logs: "User has logged in" "Course module viewed" Switch back to the other window with the platform student Edit your profile, changing your surname Save the change Go to the course Launch the tool once again Now switch back to the other window (tool site, admin user) Click "Get these logs" again Verify you now see (again near the top) the following: "User updated" "User has logged in" "Course module viewed" Switch back to the other window with the platform student Launch the tool once again (or refresh) Now switch back to the other window (tool site, admin user) Click "Get these logs" again Verify you now see (again near the top) the following: "User has logged in" "Course module viewed" Verify you don't see "User updated" among the above group of logs Now, continuing in the tool site window, go to the 'tool course' Go to "More > Published as LTI tools" in the course navigation Edit the published resource Expand "User default values" Set "Institution" to "My institution" Save the form Now go back to "Site admin > Reports >Logs" and wait there Switch back to the other window with the platform student Relaunch the tool again (or refresh the page) Switch back to the window with the tool site, admin user Click "Get these logs" once again Verify you now see (again near the top) the following: "User updated" "User has logged in" "Course module viewed" Keep this page open for the next section of testing Testing names and roles sync-based updates to the user Open up a terminal in the web root of your tool site Run the following to sync members from the platform site: php admin/cli/scheduled_task.php --execute="enrol_lti\local\ltiadvantage\task\sync_members" Verify you see the following log entries near the top of the results: "User created" "User updated" (we expect to see the updated log here because the user's institution, per the tool defaults, will have been updated to "My institution") "User enrolled in course" Verify you see these logs for 2 distinct users (check the description 'column') Now, run the same task again: php admin/cli/scheduled_task.php --execute="enrol_lti\local\ltiadvantage\task\sync_members" Go back to the logs page and click "Get these logs" again Verify that you don't see any "User created" or "User updated" logs for the recent run of the task (you can check the times of the log entries to correlate these) Click the name of one of the user who was created and then updated. Edit their profile Expand "Optional" Verify that under "Institution" you see "My institution"

       Suppose we have a client platform and a server platform.
      On the client platform we create a course, enroll a student (JOHN SMITH), create a lti activity pointing to the server platform.
      We log into the client platform with the student and use the lti activity. Let's move to the server platform and launch the task \enrol_lti\local\ltiadvantage\task\sync_members.
      On first run it will synchronize the user on the server with the user on the client by updating the user, and that's OK.
      NOW ATTENTION: FROM THE NEXT RUN, EVEN IF NOTHING HAS CHANGED, USER JOHN SMITH WILL CONTINUE TO UPDATE TWICE.
      CONSEQUENCES: the user_updated event will be triggered 2 times writing 2 records in the log table. If we think of a platform with thousands of lti users with an average of N tools per user, if this task runs every half hour (as by default), hundreds of thousands of records will be written every day up to a few million (as in our case) of records in the log table.

      The database grows exponentially (in our case about 1GB per day).
      We have analyzed the code and we think that a check could be inserted to verify that the user record actually needs to be updated (and not just for timemodified as it happens now). There would actually be 2 checks as the update is done 2 times: one in the auth/lti/auth.php file around line 380 before calling the user_update_user($update) function and the second in the enrol\lti\classes file \local\ltiadvantage\repository\user_repository.php before calling the same function as before on line 167 (function save).

      I apologize in advance if something is not clear but the concept is complex, I am available for clarification.

        1. MDL-76842-401.jpg
          MDL-76842-401.jpg
          470 kB
        2. MDL-76841-master.jpg
          MDL-76841-master.jpg
          479 kB
        3. MDL-76841-master_003.png
          MDL-76841-master_003.png
          121 kB
        4. MDL-76841-402.jpg
          MDL-76841-402.jpg
          484 kB
        5. master - scenario 3 - step-3.png
          master - scenario 3 - step-3.png
          937 kB
        6. master - scenario 2 - step-41.png
          master - scenario 2 - step-41.png
          984 kB
        7. master - scenario 2 - step-28.png
          master - scenario 2 - step-28.png
          964 kB
        8. master - scenario 2 - step-24.png
          master - scenario 2 - step-24.png
          919 kB
        9. master - scenario 2 - step-16.png
          master - scenario 2 - step-16.png
          968 kB
        10. master - scenario 2 - step-11.png
          master - scenario 2 - step-11.png
          957 kB
        11. 400_step41.png
          400_step41.png
          92 kB
        12. 400_step28.png
          400_step28.png
          74 kB
        13. 400_step24.png
          400_step24.png
          90 kB
        14. 400_step16.png
          400_step16.png
          75 kB
        15. 400_step11.png
          400_step11.png
          121 kB
        16. 400_scenario2step3.png
          400_scenario2step3.png
          124 kB
        17. 400_scenario2step2.png
          400_scenario2step2.png
          75 kB

            jaked Jake Dallimore
            atty1985 Attilio Ferrari
            Stevani Andolo Stevani Andolo
            Jun Pataleta Jun Pataleta
            Ferran Recio Ferran Recio
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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