Skip to content

Commit

Permalink
Link to code examples for correct version of Moodle
Browse files Browse the repository at this point in the history
If we do not do this users may see and use features that are not part of the Moodle version they are coding for
  • Loading branch information
NeillM committed Dec 2, 2024
1 parent e6196c6 commit ad66b69
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Most filter types use an `operator` for field to define which of their operators

The operator you have defined will then determine which other form fields you will need to provide values for, in our example so far that would be `value` which would be defined as `'course_categotry:name_value' => 'The name of a category'` this would mean that only a category with that exact name would be returned by default.

[Core report builder filter types](https://github.com/moodle/moodle/tree/main/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.
[Core report builder filter types](https://github.com/moodle/moodle/tree/MOODLE_403_STABLE/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.

## Text filters

Expand Down
36 changes: 18 additions & 18 deletions versioned_docs/version-4.3/apis/core/reportbuilder/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Column instances define the data captured/displayed within a report column typic

#### Creating columns

To create a new column, just create a new instance of [`reportbuilder/classes/local/report/column.php`](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/report/column.php) class with:
To create a new column, just create a new instance of [`reportbuilder/classes/local/report/column.php`]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/report/column.php) class with:

```php
* string $name
Expand Down Expand Up @@ -81,20 +81,20 @@ Filters & columns are entirely separate concepts in the report, and each can be

#### Filter types

- **Text** ([reportbuilder/classes/local/filters/text.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/text.php))
- **Date** ([reportbuilder/classes/local/filters/date.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/date.php))
- **Number** ([reportbuilder/classes/local/filters/number.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/number.php))
- **Boolean Select** ([reportbuilder/classes/local/filters/boolean_select.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/boolean_select.php))
- **Select** ([reportbuilder/classes/local/filters/select.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/select.php))
- **Course selector** ([reportbuilder/classes/local/filters/course_selector.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/course_selector.php))
- **Duration** ([reportbuilder/classes/local/filters/duration.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/duration.php))
- **Tags** ([reportbuilder/classes/local/filters/tags.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/tags.php))
- **Autocomplete** ([reportbuilder/classes/local/filters/autocomplete.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/autocomplete.php))
- **Category** ([reportbuilder/classes/local/filters/category.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/category.php))
- **Text** ([reportbuilder/classes/local/filters/text.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/text.php))
- **Date** ([reportbuilder/classes/local/filters/date.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/date.php))
- **Number** ([reportbuilder/classes/local/filters/number.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/number.php))
- **Boolean Select** ([reportbuilder/classes/local/filters/boolean_select.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/boolean_select.php))
- **Select** ([reportbuilder/classes/local/filters/select.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/select.php))
- **Course selector** ([reportbuilder/classes/local/filters/course_selector.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/course_selector.php))
- **Duration** ([reportbuilder/classes/local/filters/duration.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/duration.php))
- **Tags** ([reportbuilder/classes/local/filters/tags.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/tags.php))
- **Autocomplete** ([reportbuilder/classes/local/filters/autocomplete.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/autocomplete.php))
- **Category** ([reportbuilder/classes/local/filters/category.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/filters/category.php))

#### Creating filters

To create a new filter, just create a new instance of **[reportbuilder/classes/local/report/filter.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/report/filter.php)** class with:
To create a new filter, just create a new instance of **[reportbuilder/classes/local/report/filter.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/local/report/filter.php)** class with:

```php
* string $filterclass
Expand Down Expand Up @@ -196,7 +196,7 @@ System reports are a consistent way of providing reporting data, with paging, fi

### Create a new system report using entities

To create a new system report just create a new class extending [reportbuilder/classes/system_report.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/system_report.php).
To create a new system report just create a new class extending [reportbuilder/classes/system_report.php]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/system_report.php).

The first method that we need is ***initialise()*** :

Expand Down Expand Up @@ -307,16 +307,16 @@ $this->set_initial_sort_column('task_log:starttime', SORT_DESC);

Check out these two system reports as an example:

- **Task logs**: [`admin/classes/reportbuilder/local/systemreports/task_logs.php`](https://github.com/moodle/moodle/blob/main/admin/classes/reportbuilder/local/systemreports/task_logs.php)
- **Config changes**: [`report/configlog/classes/reportbuilder/local/systemreports/config_changes.php`](https://github.com/moodle/moodle/blob/main/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php)
- **Task logs**: [`admin/classes/reportbuilder/local/systemreports/task_logs.php`]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/admin/classes/reportbuilder/local/systemreports/task_logs.php)
- **Config changes**: [`report/configlog/classes/reportbuilder/local/systemreports/config_changes.php`]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php)

## Custom reports

The custom reporting interface allows reports to be built with a custom view for users, Moodle and plugins can define data sources that provide the basis for the reports that users can make using the system.

### Create a new data source using entities

To create a data source you need to extend [`\core_reportbuilder\datasource`](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/datasource.php). Your class must be located in the `reportbuilder\datasource` namespace of your plugin or the Moodle subsystem it is for.
To create a data source you need to extend [`\core_reportbuilder\datasource`]( https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/reportbuilder/classes/datasource.php). Your class must be located in the `reportbuilder\datasource` namespace of your plugin or the Moodle subsystem it is for.

The first method you need to build is `initialise()`

Expand Down Expand Up @@ -612,5 +612,5 @@ The first parameter for each method is the fully qualified class name of the `da

#### Unit test examples

- **Course categories** [`/course/tests/reportbuilder/datasource/categories_test.php`](https://github.com/moodle/moodle/blob/main/course/tests/reportbuilder/datasource/categories_test.php)
- **Badges** [`/badges/tests/reportbuilder/datasource/badges_test.php`](https://github.com/moodle/moodle/blob/main/badges/tests/reportbuilder/datasource/badges_test.php)
- **Course categories** [`/course/tests/reportbuilder/datasource/categories_test.php`](https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/course/tests/reportbuilder/datasource/categories_test.php)
- **Badges** [`/badges/tests/reportbuilder/datasource/badges_test.php`](https://github.com/moodle/moodle/blob/MOODLE_403_STABLE/badges/tests/reportbuilder/datasource/badges_test.php)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Most filter types use an `operator` for field to define which of their operators

The operator you have defined will then determine which other form fields you will need to provide values for, in our example so far that would be `value` which would be defined as `'course_categotry:name_value' => 'The name of a category'` this would mean that only a category with that exact name would be returned by default.

[Core report builder filter types](https://github.com/moodle/moodle/tree/main/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.
[Core report builder filter types](https://github.com/moodle/moodle/tree/MOODLE_404_STABLE/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.

## Text filters

Expand Down
42 changes: 21 additions & 21 deletions versioned_docs/version-4.4/apis/core/reportbuilder/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Column instances define the data captured/displayed within a report column typic

#### Creating columns

To create a new column, just create a new instance of [`reportbuilder/classes/local/report/column.php`](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/report/column.php) class with:
To create a new column, just create a new instance of [`reportbuilder/classes/local/report/column.php`]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/report/column.php) class with:

```php
* string $name
Expand Down Expand Up @@ -81,20 +81,20 @@ Filters & columns are entirely separate concepts in the report, and each can be

#### Filter types

- **Text** ([reportbuilder/classes/local/filters/text.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/text.php))
- **Date** ([reportbuilder/classes/local/filters/date.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/date.php))
- **Number** ([reportbuilder/classes/local/filters/number.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/number.php))
- **Boolean Select** ([reportbuilder/classes/local/filters/boolean_select.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/boolean_select.php))
- **Select** ([reportbuilder/classes/local/filters/select.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/select.php))
- **Course selector** ([reportbuilder/classes/local/filters/course_selector.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/course_selector.php))
- **Duration** ([reportbuilder/classes/local/filters/duration.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/duration.php))
- **Tags** ([reportbuilder/classes/local/filters/tags.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/tags.php))
- **Autocomplete** ([reportbuilder/classes/local/filters/autocomplete.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/autocomplete.php))
- **Category** ([reportbuilder/classes/local/filters/category.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/filters/category.php))
- **Text** ([reportbuilder/classes/local/filters/text.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/text.php))
- **Date** ([reportbuilder/classes/local/filters/date.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/date.php))
- **Number** ([reportbuilder/classes/local/filters/number.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/number.php))
- **Boolean Select** ([reportbuilder/classes/local/filters/boolean_select.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/boolean_select.php))
- **Select** ([reportbuilder/classes/local/filters/select.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/select.php))
- **Course selector** ([reportbuilder/classes/local/filters/course_selector.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/course_selector.php))
- **Duration** ([reportbuilder/classes/local/filters/duration.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/duration.php))
- **Tags** ([reportbuilder/classes/local/filters/tags.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/tags.php))
- **Autocomplete** ([reportbuilder/classes/local/filters/autocomplete.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/autocomplete.php))
- **Category** ([reportbuilder/classes/local/filters/category.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/filters/category.php))

#### Creating filters

To create a new filter, just create a new instance of **[reportbuilder/classes/local/report/filter.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/report/filter.php)** class with:
To create a new filter, just create a new instance of **[reportbuilder/classes/local/report/filter.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/report/filter.php)** class with:

```php
* string $filterclass
Expand Down Expand Up @@ -126,7 +126,7 @@ All report elements can be defined within the reports themselves - but entities

#### Create an entity

To create an entity, the new entity class must extend **[reportbuilder/classes/local/entities/base.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/entities/base.php)** class and must include these methods:
To create an entity, the new entity class must extend **[reportbuilder/classes/local/entities/base.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/entities/base.php)** class and must include these methods:

```php
get_default_tables()
Expand Down Expand Up @@ -171,8 +171,8 @@ $join = "JOIN {user} {$useralias} ON {$useralias}.id = {$logalias}.relateduser"

Check out these two entities as an example to start building reports:

- **User entity**: [reportbuilder/classes/local/entities/user.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/entities/user.php)
- **Course entity**: [reportbuilder/classes/local/entities/course.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/local/entities/course.php)
- **User entity**: [reportbuilder/classes/local/entities/user.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/entities/user.php)
- **Course entity**: [reportbuilder/classes/local/entities/course.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/local/entities/course.php)

### Actions

Expand All @@ -196,7 +196,7 @@ System reports are a consistent way of providing reporting data, with paging, fi

### Create a new system report using entities

To create a new system report just create a new class extending [reportbuilder/classes/system_report.php](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/system_report.php).
To create a new system report just create a new class extending [reportbuilder/classes/system_report.php]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/system_report.php).

The first method that we need is ***initialise()*** :

Expand Down Expand Up @@ -324,16 +324,16 @@ $join = "JOIN {user} {$useralias} ON {$useralias}.id = {$logalias}.relateduser"

Check out these two system reports as an example:

- **Task logs**: [`admin/classes/reportbuilder/local/systemreports/task_logs.php`](https://github.com/moodle/moodle/blob/main/admin/classes/reportbuilder/local/systemreports/task_logs.php)
- **Config changes**: [`report/configlog/classes/reportbuilder/local/systemreports/config_changes.php`](https://github.com/moodle/moodle/blob/main/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php)
- **Task logs**: [`admin/classes/reportbuilder/local/systemreports/task_logs.php`]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/admin/classes/reportbuilder/local/systemreports/task_logs.php)
- **Config changes**: [`report/configlog/classes/reportbuilder/local/systemreports/config_changes.php`]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php)

## Custom reports

The custom reporting interface allows reports to be built with a custom view for users, Moodle and plugins can define data sources that provide the basis for the reports that users can make using the system.

### Create a new data source using entities

To create a data source you need to extend [`\core_reportbuilder\datasource`](https://github.com/moodle/moodle/blob/main/reportbuilder/classes/datasource.php). Your class must be located in the `reportbuilder\datasource` namespace of your plugin or the Moodle subsystem it is for.
To create a data source you need to extend [`\core_reportbuilder\datasource`]( https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/reportbuilder/classes/datasource.php). Your class must be located in the `reportbuilder\datasource` namespace of your plugin or the Moodle subsystem it is for.

The first method you need to build is `initialise()`

Expand Down Expand Up @@ -644,5 +644,5 @@ The first parameter for each method is the fully qualified class name of the `da

#### Unit test examples

- **Course categories** [`/course/tests/reportbuilder/datasource/categories_test.php`](https://github.com/moodle/moodle/blob/main/course/tests/reportbuilder/datasource/categories_test.php)
- **Badges** [`/badges/tests/reportbuilder/datasource/badges_test.php`](https://github.com/moodle/moodle/blob/main/badges/tests/reportbuilder/datasource/badges_test.php)
- **Course categories** [`/course/tests/reportbuilder/datasource/categories_test.php`](https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/course/tests/reportbuilder/datasource/categories_test.php)
- **Badges** [`/badges/tests/reportbuilder/datasource/badges_test.php`](https://github.com/moodle/moodle/blob/MOODLE_404_STABLE/badges/tests/reportbuilder/datasource/badges_test.php)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Most filter types use an `operator` for field to define which of their operators

The operator you have defined will then determine which other form fields you will need to provide values for, in our example so far that would be `value` which would be defined as `'course_categotry:name_value' => 'The name of a category'` this would mean that only a category with that exact name would be returned by default.

[Core report builder filter types](https://github.com/moodle/moodle/tree/main/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.
[Core report builder filter types](https://github.com/moodle/moodle/tree/MOODLE_405_STABLE/reportbuilder/classes/local/filters) you can find what a filter type needs by looking at their `get_sql_filter()` method.

## Text filters

Expand Down
Loading

0 comments on commit ad66b69

Please sign in to comment.