Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #100: add filters for rules table #117

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions classes/reportbuilder/local/entities/rule_entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
namespace tool_dynamic_cohorts\reportbuilder\local\entities;

use core_reportbuilder\local\entities\base;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\text;
use core_reportbuilder\local\report\column;
use core_reportbuilder\local\report\filter;
use lang_string;
use tool_dynamic_cohorts\rule;

Expand Down Expand Up @@ -57,6 +60,10 @@ public function initialise(): base {
$this->add_column($column);
}

foreach ($this->get_all_filters() as $filter) {
$this->add_filter($filter);
}

return $this;
}

Expand Down Expand Up @@ -174,4 +181,54 @@ protected function get_all_columns(): array {

return $columns;
}

/**
* Return list of all available filters
*
* @return filter[]
*/
protected function get_all_filters(): array {
$tablealias = $this->get_table_alias('tool_dynamic_cohorts');

// Name filter.
$filters[] = (new filter(
text::class,
'name',
new lang_string('name', 'core_cohort'),
$this->get_entity_name(),
"{$tablealias}.name"
))
->add_joins($this->get_joins());

// Bulk processing filter.
$filters[] = (new filter(
boolean_select::class,
'bulkprocessing',
new lang_string('rule_entity.bulkprocessing', 'tool_dynamic_cohorts'),
$this->get_entity_name(),
"{$tablealias}.bulkprocessing"
))
->add_joins($this->get_joins());

// Broken filter.
$filters[] = (new filter(
boolean_select::class,
'broken',
new lang_string('broken', 'tool_dynamic_cohorts'),
$this->get_entity_name(),
"{$tablealias}.broken"
))
->add_joins($this->get_joins());

// Enabled filter.
$filters[] = (new filter(
boolean_select::class,
'enabled',
new lang_string('enabled', 'tool_dynamic_cohorts'),
$this->get_entity_name(),
"{$tablealias}.enabled"
))
->add_joins($this->get_joins());
return $filters;
}
}
5 changes: 5 additions & 0 deletions classes/reportbuilder/local/systemreports/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ protected function initialise(): void {
$cohortentity->get_column('name')
->set_title(new lang_string('cohort', 'tool_dynamic_cohorts'));

$this->add_filter_from_entity('rule_entity:name');
$this->add_filter_from_entity('rule_entity:bulkprocessing');
$this->add_filter_from_entity('rule_entity:broken');
$this->add_filter_from_entity('rule_entity:enabled');

$this->set_initial_sort_column('rule_entity:name', SORT_ASC);
}

Expand Down
1 change: 1 addition & 0 deletions lang/en/tool_dynamic_cohorts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
$string['any'] = 'Any';
$string['backtolistofrules'] = 'Back to the list of rules';
$string['before'] = 'Before';
$string['broken'] = 'Broken';
$string['brokenruleswarning'] = 'There are some broken rules require your attention. <br /> To fix a broken rule you should remove all broken conditions. <br />Sometimes a rule becomes broken when matching users SQL failed. In this case all condition are ok, but the rule is marked as broken. You should check Moodle logs for "Matching users failed" event and related SQL errors. <br />Please note, that in any case you have to re-save the rule to mark it as unbroken.';
$string['bulkprocessing'] = 'Bulk processing';
$string['bulkprocessing_help'] = 'If this option is enabled, users will be added and removed from cohort in bulk. This will significantly improve processing performance. However, using this option will suppress triggering events when users added or removed from cohort.';
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'tool_dynamic_cohorts';
$plugin->release = 2024110701;
$plugin->version = 2024110701;
$plugin->release = 2024112100;
$plugin->version = 2024112100;
$plugin->requires = 2022112800;
$plugin->supported = [404, 405];
$plugin->maturity = MATURITY_STABLE;
Loading