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

Calculate custom report schedule users earlier

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78364-401
    • Hide

      Prerequisites

      1. Ensure email is configured for the site (e.g. using something like Mailhog/Mailtrap/etc)

      Setup

      1. Download me.php and save to <DIRROOT>/reportbuilder/classes/reportbuilder/audience directory
      2. Log in as admin
      3. Purge caches to ensure new audience type is detected

      Test

      1. Create new user ("Test User")
      2. Navigate to Reports from user menu
      3. Create new report from Users source
        • Include default setup = YES
      4. In report editor, add the following condition:
        • User > Select User: Current User
        • Press Apply
      5. Navigate to Audience tab
      6. Add Me site audience and save
      7. Navigate to Access tab
      8. Confirm tab lists only your own account
      9. Navigate to Schedules tab
      10. Press New schedule
        • Name: My new schedule
        • Starting from: 1 January 2028
        • View report data as: Select user
        • Select user: Test User
        • Audience: Me
        • Subject/Body: Some text
      11. Press Save
      12. In schedules list, press Actions > Send schedule and confirm the subsequent prompt
      13. Wait for cron to run, or execute it manually
      14. Navigate to Servers > Tasks > Task logs in site administration
      15. Press Actions > View for the most recent Send report schedule task log
      16. Confirm it contains "Sending to: Admin User" and does not contain "Sending to: Test User"
      17. Open email
      18. Confirm message was sent to admin user/email
      19. Open message attachment
      20. Confirm report contains details about only "Test User"
      Show
      Prerequisites Ensure email is configured for the site (e.g. using something like Mailhog/Mailtrap/etc) Setup Download me.php and save to <DIRROOT>/reportbuilder/classes/reportbuilder/audience directory Log in as admin Purge caches to ensure new audience type is detected Test Create new user ("Test User") Navigate to Reports from user menu Create new report from Users source Include default setup = YES In report editor, add the following condition: User > Select User: Current User Press Apply Navigate to Audience tab Add Me site audience and save Navigate to Access tab Confirm tab lists only your own account Navigate to Schedules tab Press New schedule Name: My new schedule Starting from: 1 January 2028 View report data as: Select user Select user: Test User Audience: Me Subject/Body: Some text Press Save In schedules list, press Actions > Send schedule and confirm the subsequent prompt Wait for cron to run, or execute it manually Navigate to Servers > Tasks > Task logs in site administration Press Actions > View for the most recent Send report schedule task log Confirm it contains "Sending to: Admin User" and does not contain "Sending to: Test User" Open email Confirm message was sent to admin user/email Open message attachment Confirm report contains details about only "Test User"

      We currently calculate the recipients to deliver scheduled reports to here:

      https://github.com/moodle/moodle/blob/2e1c6fd43e9334598f793a548685f7ef75ba2ec5/reportbuilder/classes/task/send_schedule.php#L93

      There is a slight problem if any of the audiences from which the schedule is determining recipients has checks based on the current user (because we already switched users on L76-83). Note there are no audiences in Moodle LMS that are affected by this right now

      We should calculate the recipients before any user switching happens. At the same time, we can get a small performance win, because if there are no reicipients then we don't need to spend any time running the report and exporting it to a file

      Adding affects_workplace label, because this does affect our tenancy-related audiences (which depend on capabilities per-user) - we also have a partner (elearning.co.jp) who are reporting similar

        1. MDL-78364.png
          MDL-78364.png
          256 kB
        2. me.php
          2 kB

            pholden Paul Holden
            pholden Paul Holden
            Carlos Castillo Carlos Castillo
            Andrew Lyons Andrew Lyons
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 41 minutes
                4h 41m

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