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

Make it easier for reports to provide custom filter form implementations

    XMLWordPrintable

Details

    • MOODLE_401_STABLE
    • MOODLE_401_STABLE
    • Hide

      Setup

      1. Log in as admin
      2. Navigate to Reports in user menu
      3. Create two reports:
        • My first report
        • My second report
      4. View list of custom reports
      5. Confirm Filters button is present

      Disable default filter form

      1. Edit <DIRROOT>/reportbuilder/index.php
      2. Add the following around line 51, immediately after $report is created:

        $report->set_filter_form_default(false);
        

      3. The entire block should look like

        $report = system_report_factory::create(reports_list::class, context_system::instance());
        $report->set_filter_form_default(false); // <-- add this line!
        echo $report->output();
        

      4. Reload the list of reports
      5. Confirm the Filters button is not present

      Apply report filters via WS

      1. Inspect page DOM in browser to retrieve the system report id (the data-report-id="<SYSTEMREPORTID>" attribute), e.g.:
      2. Open browser developer tools
      3. Execute the following in the Javascript console:

        require(['core_reportbuilder/local/repository/filters'], f => f.setFilters(<SYSTEMREPORTID>, '', '{"report:name_operator":1,"report:name_value":"first"}'))
        

      4. Reload the list of reports
      5. Confirm only My first report is shown
      6. Remove the $report->set_filter_form_default(false); line you added earlier in the test
      7. Reload the list of reports
      8. Confirm the Filters button shows (1) applied filter
      9. Press the Filters (1) button
      10. Confirm the Name filter is set to Contains: first
      Show
      Setup Log in as admin Navigate to Reports in user menu Create two reports: My first report My second report View list of custom reports Confirm Filters button is present Disable default filter form Edit <DIRROOT>/reportbuilder/index.php Add the following around line 51, immediately after $report is created: $report->set_filter_form_default(false); The entire block should look like $report = system_report_factory::create(reports_list::class, context_system::instance()); $report->set_filter_form_default(false); // <-- add this line! echo $report->output(); Reload the list of reports Confirm the Filters button is not present Apply report filters via WS Inspect page DOM in browser to retrieve the system report id (the data-report-id="<SYSTEMREPORTID>" attribute), e.g.: Open browser developer tools Execute the following in the Javascript console: require(['core_reportbuilder/local/repository/filters'], f => f.setFilters(<SYSTEMREPORTID>, '', '{"report:name_operator":1,"report:name_value":"first"}')) Reload the list of reports Confirm only My first report is shown Remove the $report->set_filter_form_default(false); line you added earlier in the test Reload the list of reports Confirm the Filters button shows (1) applied filter Press the Filters (1) button Confirm the Name filter is set to Contains: first
    • WP 4.0 SP7

    Description

      Mockups for MDL-75154 propose using system reports from reportbuilder, but with highly customised filter forms (horizontal, across the top of the report)

      To help achieve this, we need to:

      1. Provide API to disable the default filter form of a report;
      2. Create external WS endpoint to handle applying filters from custom filter forms

      See the POC based off these changes from MDL-75154:

      Note that MDL-75205 should also be fixed alongside this issue (helps both MDL-75154 & WP-3456)

      Attachments

        Issue Links

          Activity

            People

              pholden Paul Holden
              pholden Paul Holden
              Mikel Martín Corrales Mikel Martín Corrales
              Jun Pataleta Jun Pataleta
              Angelia Dela Cruz Angelia Dela Cruz
              Carlos Castillo, David Matamoros, Mikel Martín Corrales, Paul Holden
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                28/Nov/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours, 25 minutes
                  5h 25m