Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

reportbuilder/Adding a Filter

From MoodleDocs
Revision as of 14:06, 24 June 2022 by Andrew Nicols (talk | contribs) (Note about plan not to migrate this page to the new developer resources. See template for more info.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


Back to Index

Here is a simple filter option to add a text-based search field on the course fullname column we created earlier.

$this->filteroptions = array(
    new rb_filter_option(
        'course',
        'fullname',
        'Course Name',
        'text'
    )
);

Every filter option object must include 4 required arguments:

  • Column Type. Must match the type of an existing column option.
  • Column Value. Must match the value of an existing column option. The filter will act on the column option matched by the type and value.
  • Filter name. A string which describes the filter. This appears in the pulldown menu when choosing filters, and also next to the filter in the report.
  • Filter type. Defines the behaviour of the filter (e.g. text field, pulldown, checkbox etc.)

The filter types are modular, allowing new filter types to be written. The available filter types are found in local/reportbuilder/filters/. Some common filter types include:

  • text: Match text entered into a text field
  • select: Choose from a list of predefined options
  • date: Match against a range of dates

Some filter options require additional information to be passed into the filter options, see the advanced filter options and [rb_filter_option documentation] for more information.

For details on how filter types are created, see [creating new filter options].