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

Implement custom report schedules

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • Hide

      Prerequisites

      1. Email is configured on your site (use Mailhog for testing locally)
      2. Cron is setup as per recommended frequency (or you can manually execute it)
      3. Access to the database in order to execute queries

      Setup

      1. Login as admin
      2. Create three new users (User 1, User 2, User 3)
      3. Create a new cohort
      4. Add User 1 as a member of the cohort
      5. Navigate to Reports > Report builder > Custom reports
      6. Create a new report from the Users report source
      7. Press the Audience tab
      8. Add Member of cohort audience
      9. Select your previously created cohort and save
      10. Add Manually added users audience
      11. Select User 2 and User 3 and save
      12. Press Schedules tab

      Test manual sending

      1. Press New schedule - enter the following:
        • Name: My schedule 1
        • Starting from: 1 January 2025 16:00
        • Audience: Member of cohort: My cohort
        • Subject: My first schedule
        • Body: Something
      2. Press Save
      3. Confirm the schedule is shown in report
      4. Press Send schedule action, then Confirm to confirm the action
      5. Wait for cron to execute the task
      6. Confirm you receive an email to User 1:
        • Containing the Subject/Body you previously entered
        • Containing at attachment named My schedule 1.csv
      7. Confirm the attachment content matches the report as shown in the editor

      Test schedule deletion

      1. Press Schedules tab
      2. Press Delete schedule action, then Delete to confirm the action
      3. Confirm the schedule is no longer shown in the report

      Test automated sending

      1. Press New schedule - enter the following:
        • Name: My schedule 2
        • Format: Microsoft Excel (.xlsx)
        • Starting from: select a date/time approx. two minutes in the future
        • Recurrence: Weekly
        • Audience: Manually added users: User 02, User 03
        • Subject: My second schedule
        • Body: Something else
      2. Press Save
      3. Confirm the schedule is shown in report
      4. Wait for cron to execute the task
      5. Confirm you receive two emails:
        • One for User 2 and one for User 3
        • Containing the Subject/Body you previously entered
        • Containing at attachment named My schedule 2.xlsx
      6. Confirm the attachment content matches the report as shown in the editor

      Confirm recurrence was correctly calculated

      1. From your database terminal, execute the following:

        SELECT * FROM mdl_reportbuilder_schedule;
        

      2. Copy the timescheduled, timelastsent and timenextsend timestamp values
      3. Use https://www.unixtimestamp.com/ to convert the timestamps to human-readable values
      4. Confirm timescheduled is the time you set to start the schedule
      5. Confirm timelastsent is the time the schedule was actually sent
      6. Confirm timenextsend is exactly one week after timescheduled
      7. They should look something like this (dependent on when exactly you are performing this test ):

        $ date -d @1639754400 #timescheduled
        Fri 17 Dec 15:20:00 GMT 2021
        $ date -d @1639754416 #timelastsent
        Fri 17 Dec 15:20:16 GMT 2021
        $ date -d @1640359200 #timenextsend
        Fri 24 Dec 15:20:00 GMT 2021
        

      Show
      Prerequisites Email is configured on your site (use Mailhog for testing locally) Cron is setup as per recommended frequency (or you can manually execute it) Access to the database in order to execute queries Setup Login as admin Create three new users (User 1, User 2, User 3) Create a new cohort Add User 1 as a member of the cohort Navigate to Reports > Report builder > Custom reports Create a new report from the Users report source Press the Audience tab Add Member of cohort audience Select your previously created cohort and save Add Manually added users audience Select User 2 and User 3 and save Press Schedules tab Test manual sending Press New schedule - enter the following: Name: My schedule 1 Starting from: 1 January 2025 16:00 Audience: Member of cohort: My cohort Subject: My first schedule Body: Something Press Save Confirm the schedule is shown in report Press Send schedule action, then Confirm to confirm the action Wait for cron to execute the task Confirm you receive an email to User 1 : Containing the Subject/Body you previously entered Containing at attachment named My schedule 1.csv Confirm the attachment content matches the report as shown in the editor Test schedule deletion Press Schedules tab Press Delete schedule action, then Delete to confirm the action Confirm the schedule is no longer shown in the report Test automated sending Press New schedule - enter the following: Name: My schedule 2 Format: Microsoft Excel (.xlsx) Starting from: select a date/time approx. two minutes in the future Recurrence: Weekly Audience: Manually added users: User 02, User 03 Subject: My second schedule Body: Something else Press Save Confirm the schedule is shown in report Wait for cron to execute the task Confirm you receive two emails: One for User 2 and one for User 3 Containing the Subject/Body you previously entered Containing at attachment named My schedule 2.xlsx Confirm the attachment content matches the report as shown in the editor Confirm recurrence was correctly calculated From your database terminal, execute the following: SELECT * FROM mdl_reportbuilder_schedule; Copy the timescheduled , timelastsent and timenextsend timestamp values Use https://www.unixtimestamp.com/ to convert the timestamps to human-readable values Confirm timescheduled is the time you set to start the schedule Confirm timelastsent is the time the schedule was actually sent Confirm timenextsend is exactly one week after timescheduled They should look something like this (dependent on when exactly you are performing this test ): $ date -d @1639754400 #timescheduled Fri 17 Dec 15:20:00 GMT 2021 $ date -d @1639754416 #timelastsent Fri 17 Dec 15:20:16 GMT 2021 $ date -d @1640359200 #timenextsend Fri 24 Dec 15:20:00 GMT 2021

      The goal of this task is to allow report editors to configure the automatic delivery of reports to specific audiences (MDL-72588) via email

      Each schedule contains three parts:

      Basic information

      • Schedule name is only used in the list of schedules
      • Format: Any file format that has been allowed in Site administration > Plugins > Data formats > Manage data formats
      • Date: Specifies when the report is to be sent for the first time
      • Recurrence: whether the report should be sent once (Does not repeat) or sent frequently (Daily, Weekly, Monthly, Annually, Daily – Weekdays)
      • If the report is empty: what to do in this case
        • Send email without the report
        • Send email with an empty report
        • Don't send the email
      • View report data as:
        • Schedule creator
        • Schedule recipient
        • Specific user

      Recipients: define which users will receive the scheduled report by selecting at least one report audience

      Custom message: Standard elements of any email message, namely Subject and Message.

      The cron process will trigger the execution of the report.

      The report can be sent immediately using the "Send option" from the actions in the list of schedules. When using this option, the user will be asked to confirm the action. The text in the confirmation dialog will depend on the "if report is empty" setting value:

      • If "Do not send email" is selected, we add a warning note.
        • Are you sure you want to queue 'Schedule' for sending? (Note no email will be sent if the report is empty)
      • Otherwise, we just ask for confirmation:
        • Are you sure you want to queue 'Schedule' for sending?

      (see Rafael's comment for prototypes)

            pholden Paul Holden
            pholden Paul Holden
            David Carrillo David Carrillo
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 weeks, 4 hours, 40 minutes
                3w 4h 40m

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