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

Report builder: Implement functionality for creating system reports

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Automated tests can be run via the following:

      $ vendor/bin/phpunit --testsuite core_reportbuilder_testsuite
      

       

      We have created a plugin with a demo report to test system reports functionality. It also contains a Behat test to check report content, columns and filters. This plugin can be downloaded from https://github.com/dravek/moodle-local_reportbuilderdemo .

      1. Download and install this demo plugin in the local folder of your testing instance:

        git clone https://github.com/dravek/moodle-local_reportbuilderdemo.git local/reportbuilderdemo

      2. Create 3 courses in your instance:
        • fullname: Course 1, shortname: C1
        • fullname: Course 2, shortname: C2
        • fullname: Course 3, shortname: C3
      3. Go to Site Administration > Development > Report Builder - Course report demo
      4. Confirm that the report is shown, the title is 'Report Builder - Course report demo' and that contains the 3 courses we have just created.
      5. Confirm that report contains 7 columns: Course full name with link, Course short name, Course category, Format, Course start date, Course end date and Course visibility.
      6. Click on the 'Filters' button and the filters form should appear. You should see one filter for each column.
      7. Select 'Is equal to' in the 'Course short name' filter. A new empty text input field should appear next to the selector we just changed. Type 'C3' in this new field.
      8. Click on 'Apply'.
      9. Confirm that now the report only shows one row containing 'Course 3' and we don't see 'Course 1' or 'Course 2'.
      10. Click on 'Reset all'.
      11. Confirm that we see all three courses again in our report.
      12. Click on 'Course full name with link' column title and confirm it orders the courses by name ASC. Click again and it show order them by name DESC.
      13. Click on 'Reset table preferences' to get back to default report order.
      14. Select 'Microsoft Excel' in the Download selector and click the 'Download' button. Confirm that the excel file that has been downloaded contains all report data.
      15. Click on Course 2 name link and confirm it goes to the course page.
      16. Now go to Site Administration > Development > Report Builder - User and Course report demo.
      17. Confirm that the page contains 2 reports, first one report with the list of courses and then one report with the list of users.
      18. Repeat steps from 6 to 11 to confirm that filters keep working well even if we have multiple system reports instances on the same page.
      19. Run the automated Behat test in the plugin:

      mdk behat -r --tags=@local_reportbuilderdemo

       

      Show
      Automated tests can be run via the following: $ vendor/bin/phpunit --testsuite core_reportbuilder_testsuite   We have created a plugin with a demo report to test system reports functionality. It also contains a Behat test to check report content, columns and filters. This plugin can be downloaded from https://github.com/dravek/moodle-local_reportbuilderdemo . Download and install this demo plugin in the local folder of your testing instance: git clone https: //github.com/dravek/moodle-local_reportbuilderdemo.git local/reportbuilderdemo Create 3 courses in your instance: fullname: Course 1, shortname: C1 fullname: Course 2, shortname: C2 fullname: Course 3, shortname: C3 Go to Site Administration > Development > Report Builder - Course report demo Confirm that the report is shown, the title is 'Report Builder - Course report demo' and that contains the 3 courses we have just created. Confirm that report contains 7 columns: Course full name with link, Course short name, Course category, Format, Course start date, Course end date and Course visibility. Click on the 'Filters' button and the filters form should appear. You should see one filter for each column. Select 'Is equal to' in the 'Course short name' filter. A new empty text input field should appear next to the selector we just changed. Type 'C3' in this new field. Click on 'Apply'. Confirm that now the report only shows one row containing 'Course 3' and we don't see 'Course 1' or 'Course 2'. Click on 'Reset all'. Confirm that we see all three courses again in our report. Click on 'Course full name with link' column title and confirm it orders the courses by name ASC. Click again and it show order them by name DESC. Click on 'Reset table preferences' to get back to default report order. Select 'Microsoft Excel' in the Download selector and click the 'Download' button. Confirm that the excel file that has been downloaded contains all report data. Click on Course 2 name link and confirm it goes to the course page. Now go to Site Administration > Development > Report Builder - User and Course report demo. Confirm that the page contains 2 reports, first one report with the list of courses and then one report with the list of users. Repeat steps from 6 to 11 to confirm that filters keep working well even if we have multiple system reports instances on the same page. Run the automated Behat test in the plugin: mdk behat -r --tags= @local_reportbuilderdemo  
    • Affected Branches:
      MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_400_STABLE
    • Pull Master Branch:
    • Sprint:
      WP 3.11 SP 1

      Description

      Create all APIs, tests, documentation, examples to allow for the creation of system reports

      For a pictorial overview of a system report please refer to reportbuilder_overview.pdf

      Columns

      Column instances define the data captured/displayed within a report column - typically:

      • How the data is retrieved, either a simple SQL table.field fragment or an expression that returns a value
      • They type of data that is being retrieved (int, text, datetime, etc)
      • How that data should be presented in a report (for instance calling userdate() on datetime types)

      Filters

      Report filters can be defined for a report and allow users to narrow down (filter) the data that is displayed in a report

      • They define the data being filtered, either a simple SQL fragment or expression
      • The type of filtering being performed (int, text, datetime, etc)

      Filter types are extendable, allowing for the addition of many more as suits each use case. We have provided common ones that cover most use cases

      Note that filters & columns are entirely separate concepts in the report, and each can be used without a matching column/filter (that is to say, we can add a report filter for a user field without needing the column for the same field to be present in the report)

      Entities

      Entities are simply collections of report elements (currently columns and filters). They allow for common elements to be defined once, and then re-used in all reports - developers can choose to use as many or as few of the elements from each entity as required. We have provided user and course entities. They can be joined to reports using standard SQL query syntax

      All report elements can be defined within the reports themselves - but entities mean it's much easier to create re-usable components, and will also help in the long term with custom reports

      Actions

      Report actions can be defined in system reports to provide CTA links for each row in the report. Using :placeholder elements in the action URLs allows them to be specific to the row content - e.g. to always provide a link to the current user/course of the current row

      System reports

      System reports are a consistent way of providing reporting data, with paging, filtering, exporting standardized across them. Once the groundwork is done in defining the report elements in entities, it's possible to implement them with minimal code just by adding entities to the report, and defining which elements you want to use from them

        Attachments

        1. MDL-70794_Screenshot1.png
          897 kB
          Gladys Basiana
        2. MDL-70794_Screenshot2.png
          568 kB
          Gladys Basiana
        3. reportbuilder_overview.pdf
          83 kB
          David Matamoros

          Issue Links

            Activity

              People

              Assignee:
              pholden Paul Holden
              Reporter:
              pholden Paul Holden
              Peer reviewer:
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Integrator:
              Adrian Greeve Adrian Greeve
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              David Matamoros, Paul Holden
              Votes:
              2 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Dec/21

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 17 weeks, 2 days, 3 hours, 35 minutes
                  17w 2d 3h 35m