Skip to content

Commit 5cdda4d

Browse files
committed
Fix bunch of coding style issues
1 parent 21baa67 commit 5cdda4d

20 files changed

+203
-200
lines changed

lang/en/tool_dynamic_cohorts.php

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
defined('MOODLE_INTERNAL') || die();
2727

28+
$string['add_rule'] = 'Add new rule';
2829
$string['addcondition'] = 'Add a condition';
2930
$string['addrule'] = 'Add a new rule';
30-
$string['add_rule'] = 'Add new rule';
3131
$string['after'] = 'After';
3232
$string['any'] = 'Any';
3333
$string['before'] = 'Before';
@@ -38,92 +38,95 @@
3838
$string['cachedef_conditionrecords'] = 'Conditions for a rule';
3939
$string['cachedef_matchingusers'] = 'Matching users for a rule';
4040
$string['cachedef_rulesconditions'] = 'Rules with a specific condition';
41+
$string['cannotenablebrokenrule'] = 'A broken rule can\'t be enabled';
42+
$string['cf_include_missing_data'] = 'Include cohorts with missing data.';
43+
$string['cf_include_missing_data_help'] = 'Cohorts may not have a custom field data set yet. This option includes those cohorts in the final result.';
44+
$string['cf_includingmissingdatadesc'] = '(including cohorts with missing data)';
4145
$string['cohort'] = 'Cohort';
4246
$string['cohortid'] = 'Cohort';
43-
$string['cohortswith'] = 'Cohort(s) with field';
4447
$string['cohortid_help'] = 'A cohort to manage as part of this rule. Only cohorts that are not managed by other plugins are displayed in this list.';
48+
$string['cohortswith'] = 'Cohort(s) with field';
4549
$string['completed:add'] = 'Rule has been added';
4650
$string['completed:delete'] = 'Rule has been deleted';
47-
$string['completed:enable'] = 'Rule has been enabled';
4851
$string['completed:disable'] = 'Rule has been disabled';
52+
$string['completed:enable'] = 'Rule has been enabled';
4953
$string['completed:update'] = 'Rule has been updated';
5054
$string['completiondate'] = 'Completion date';
5155
$string['completionisdisabled'] = 'Completion is disabled for configured course';
5256
$string['condition'] = 'Condition';
53-
$string['conditions'] = 'Conditions';
54-
$string['conditionstext'] = '{$a->conditions} ( logical {$a->operator} )';
55-
$string['conditionsformtitle'] = 'Rule conditions';
56-
$string['conditionchnagesnotapplied'] = 'Condition changes are not applied until you save the rule form';
57-
$string['conditionformtitle'] = 'Rule condition';
5857
$string['condition:auth_method'] = 'Authentication method';
59-
$string['condition:cohort_membership'] = 'Cohort membership';
60-
$string['condition:cohort_membership_description'] = 'Users who {$a->operator} {$a->cohorts}';
61-
$string['condition:cohort_membership_broken_description'] = 'Condition is broken. Using the same cohort that the given rule is configured to manage to.';
6258
$string['condition:cohort_field'] = 'Cohort field';
6359
$string['condition:cohort_field_description'] = 'Users who {$a->operator} cohorts with field \'{$a->field}\' {$a->fieldoperator} {$a->fieldvalue}';
60+
$string['condition:cohort_membership'] = 'Cohort membership';
61+
$string['condition:cohort_membership_broken_description'] = 'Condition is broken. Using the same cohort that the given rule is configured to manage to.';
62+
$string['condition:cohort_membership_description'] = 'Users who {$a->operator} {$a->cohorts}';
6463
$string['condition:course_completed'] = 'Course completed';
6564
$string['condition:course_completed_description'] = 'Users who have completed course "{$a->course}" {$a->operator} {$a->timecompleted}';
6665
$string['condition:course_not_completed'] = 'Course not completed';
6766
$string['condition:course_not_completed_description'] = 'Users who have not completed course "{$a->course}"';
6867
$string['condition:profile_field_description'] = 'Users with {$a->field} {$a->fieldoperator} {$a->fieldvalue}';
68+
$string['condition:user_created'] = 'User created time';
69+
$string['condition:user_custom_profile'] = 'User custom profile field';
6970
$string['condition:user_enrolment'] = 'User enrolment';
7071
$string['condition:user_enrolment_description'] = 'Users who are {$a->operator} into course "{$a->coursename}" (id {$a->courseid}) with "{$a->role}" role using "{$a->enrolmethod}" enrolment method';
7172
$string['condition:user_last_login'] = 'User last login';
72-
$string['condition:user_created'] = 'User created time';
7373
$string['condition:user_profile'] = 'User standard profile field';
7474
$string['condition:user_profile_interests'] = 'User interests';
7575
$string['condition:user_profile_interests_description'] = 'Users with interests containing the following tags {$a}';
7676
$string['condition:user_profile_interests_description_not'] = 'Users with interests not containing the following tags {$a}';
77-
$string['condition:user_custom_profile'] = 'User custom profile field';
7877
$string['condition:user_role'] = 'User role';
79-
$string['condition:user_role_description_system'] = 'Users who {$a->operator} "{$a->role}" in system context';
8078
$string['condition:user_role_description_category'] = 'Users who {$a->operator} "{$a->role}" in category {$a->categoryname} (id {$a->categoryid})';
8179
$string['condition:user_role_description_course'] = 'Users who {$a->operator} "{$a->role}" in course {$a->coursename} (id {$a->courseid})';
82-
$string['cf_include_missing_data'] = 'Include cohorts with missing data.';
83-
$string['cf_include_missing_data_help'] = 'Cohorts may not have a custom field data set yet. This option includes those cohorts in the final result.';
84-
$string['cf_includingmissingdatadesc'] = '(including cohorts with missing data)';
80+
$string['condition:user_role_description_system'] = 'Users who {$a->operator} "{$a->role}" in system context';
81+
$string['conditionchnagesnotapplied'] = 'Condition changes are not applied until you save the rule form';
82+
$string['conditionformtitle'] = 'Rule condition';
83+
$string['conditions'] = 'Conditions';
84+
$string['conditionsformtitle'] = 'Rule conditions';
85+
$string['conditionstext'] = '{$a->conditions} ( logical {$a->operator} )';
8586
$string['delete_confirm'] = 'Are you sure you want to delete rule?';
8687
$string['delete_confirm_condition'] = 'Are you sure you want to delete this condition?';
8788
$string['delete_rule'] = 'Delete rule';
8889
$string['description'] = 'Description';
8990
$string['description_help'] = 'As short description of this rule';
90-
$string['disabled'] = 'Disabled';
9191
$string['disable_confirm'] = 'Are you sure you want to disable rule?';
92+
$string['disabled'] = 'Disabled';
93+
$string['donothaverole'] = 'do not have role';
9294
$string['dynamic_cohorts:manage'] = 'Manage rules';
9395
$string['edit_rule'] = 'Edit rule';
94-
$string['enabled'] = 'Enabled';
9596
$string['enable_confirm'] = 'Are you sure you want to enable rule?';
96-
$string['enrolmethod'] = 'Enrolment method';
97+
$string['enabled'] = 'Enabled';
9798
$string['enrolled'] = 'Enrolled';
98-
$string['ever'] = 'Ever';
99-
$string['everloggedin'] = 'Users who have logged in at least once';
99+
$string['enrolmethod'] = 'Enrolment method';
100100
$string['event:conditioncreated'] = 'Condition created';
101101
$string['event:conditiondeleted'] = 'Condition deleted';
102102
$string['event:conditionupdated'] = 'Condition updated';
103103
$string['event:matchingfailed'] = 'Matching users failed';
104104
$string['event:rulecreated'] = 'Rule created';
105-
$string['event:ruleupdated'] = 'Rule updated';
106105
$string['event:ruledeleted'] = 'Rule deleted';
107-
$string['includechildren'] = 'including children (categories and courses)';
108-
$string['includingmissingdatadesc'] = '(including users with missing data)';
109-
$string['includeusersmissingdata'] = 'include users with missing data';
106+
$string['event:ruleupdated'] = 'Rule updated';
107+
$string['ever'] = 'Ever';
108+
$string['everloggedin'] = 'Users who have logged in at least once';
109+
$string['haverole'] = 'have role';
110110
$string['include_missing_data'] = 'Include users with missing data.';
111111
$string['include_missing_data_help'] = 'Some users may not have a custom field data set yet. This option includes those user in the final result.';
112+
$string['includechildren'] = 'including children (categories and courses)';
113+
$string['includeusersmissingdata'] = 'include users with missing data';
114+
$string['includingmissingdatadesc'] = '(including users with missing data)';
112115
$string['inlast'] = 'In the last';
113116
$string['inlastloggedin'] = 'Users who have logged in in the last {$a}';
117+
$string['inthefuture'] = 'is in the future';
118+
$string['inthepast'] = 'is in the past';
114119
$string['invalidfieldvalue'] = 'Invalid field value';
115-
$string['ismemberof'] = 'are members of';
116-
$string['isnotmemberof'] = 'are not members of';
117-
$string['isnotempty'] = 'is not empty';
118120
$string['isafter'] = 'is after';
119121
$string['isbefore'] = 'is before';
120-
$string['inthepast'] = 'is in the past';
121-
$string['inthefuture'] = 'is in the future';
122+
$string['ismemberof'] = 'are members of';
123+
$string['isnotempty'] = 'is not empty';
124+
$string['isnotmemberof'] = 'are not members of';
122125
$string['loggedintime'] = 'Users who logged in {$a->operator} {$a->time}';
123126
$string['logical_operator'] = 'Logical operator';
124127
$string['logical_operator_help'] = 'A logical operator to be applied to conditions for this rule. Operator "AND" means a user has to match all conditions to be added to a cohort. "OR" means a user has to match any of conditions to be added to a cohort.';
125-
$string['managerules'] = 'Manage rules';
126128
$string['managecohorts'] = 'Manage cohorts';
129+
$string['managerules'] = 'Manage rules';
127130
$string['matchingusers'] = 'Matching users';
128131
$string['missingcourse'] = 'Missing course';
129132
$string['missingcoursecat'] = 'Missing course category';
@@ -147,29 +150,26 @@
147150
$string['privacy:metadata:tool_dynamic_cohorts_c:usermodified'] = 'The ID of the user who created or updated a condition';
148151
$string['processrulestask'] = 'Process dynamic cohort rules';
149152
$string['profilefield'] = 'Profile field';
150-
$string['cannotenablebrokenrule'] = 'A broken rule can\'t be enabled';
151-
$string['ruledisabledpleasereview'] = 'Newly created or updated rules are disabled by default. Please review the rule below and enable it when ready.';
152-
$string['ruledeleted'] = 'Rule has been deleted';
153-
$string['ruleenabled'] = 'Rule has been enabled';
154-
$string['ruledisabled'] = 'Rule has been disabled';
153+
$string['realtime'] = 'Real time processing';
154+
$string['realtime_help'] = 'If enabled, the rule will be processed synchronously as part of the event (if conditions support triggering on the event). Use caution when enabling as long running rule processing will block the user interface.';
155+
$string['realtimedisabledglobally'] = 'Realtime processing disabled globally';
155156
$string['rule_entity'] = 'Dynamic cohort rule';
157+
$string['rule_entity.bulkprocessing'] = 'Bulk processing';
158+
$string['rule_entity.description'] = 'Description';
156159
$string['rule_entity.id'] = 'ID';
157160
$string['rule_entity.name'] = 'Name';
158-
$string['rule_entity.description'] = 'Description';
159-
$string['rule_entity.bulkprocessing'] = 'Bulk processing';
161+
$string['rule_entity.realtime'] = 'Realtime processing';
160162
$string['rule_entity.status'] = 'Status';
163+
$string['ruledeleted'] = 'Rule has been deleted';
164+
$string['ruledisabled'] = 'Rule has been disabled';
165+
$string['ruledisabledpleasereview'] = 'Newly created or updated rules are disabled by default. Please review the rule below and enable it when ready.';
166+
$string['ruleenabled'] = 'Rule has been enabled';
161167
$string['settings:realtime'] = 'Real time processing';
162168
$string['settings:realtime_desc'] = 'When enabled, rules with conditions that support triggering on the event will be processed synchronously as part of the event. Use caution when enabling as long running rule processing will block the user interface.';
163169
$string['settings:releasemembers'] = 'Release members';
164170
$string['settings:releasemembers_desc'] = 'If enabled all members will be removed from a cohort once it\'s not managed by the plugin (e.g a rule is deleted or cohort for a rule is changed). <br/> Please note: no cohort_member_removed events will be triggered when members are released from a cohort. Otherwise, the rule will be processed via cron.';
165171
$string['usercreated'] = 'User was created';
166172
$string['usercreatedin'] = 'Users who were created in the last {$a}';
167173
$string['usercreatedtime'] = 'Users who were created {$a->operator} {$a->time}';
168-
$string['usersforrule'] = 'Users matching rule "{$a->rule}" for cohort "{$a->cohort}"';
169174
$string['userlastlogin'] = 'User\'s last login';
170-
$string['haverole'] = 'have role';
171-
$string['donothaverole'] = 'do not have role';
172-
$string['realtime'] = 'Real time processing';
173-
$string['realtime_help'] = 'If enabled, the rule will be processed synchronously as part of the event (if conditions support triggering on the event). Use caution when enabling as long running rule processing will block the user interface.';
174-
$string['rule_entity.realtime'] = 'Realtime processing';
175-
$string['realtimedisabledglobally'] = 'Realtime processing disabled globally';
175+
$string['usersforrule'] = 'Users matching rule "{$a->rule}" for cohort "{$a->cohort}"';

tests/cohort_manager_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
*
2626
* @covers \tool_dynamic_cohorts\cohort_manager
2727
*/
28-
class cohort_manager_test extends \advanced_testcase {
28+
final class cohort_manager_test extends \advanced_testcase {
2929

3030
/**
3131
* Test getting available cohorts.
3232
*/
33-
public function test_get_available_cohorts() {
33+
public function test_get_available_cohorts(): void {
3434
$this->resetAfterTest();
3535

3636
$this->assertEmpty(cohort_manager::get_cohorts());
@@ -61,7 +61,7 @@ public function test_get_available_cohorts() {
6161
/**
6262
* Test managing cohort.
6363
*/
64-
public function test_manage_cohort() {
64+
public function test_manage_cohort(): void {
6565
global $DB;
6666

6767
$this->resetAfterTest();
@@ -76,7 +76,7 @@ public function test_manage_cohort() {
7676
/**
7777
* Test unmanaging cohort.
7878
*/
79-
public function test_unmanage_cohort() {
79+
public function test_unmanage_cohort(): void {
8080
global $DB;
8181

8282
$this->resetAfterTest();
@@ -91,7 +91,7 @@ public function test_unmanage_cohort() {
9191
/**
9292
* Test un managing cohort removes members when configured.
9393
*/
94-
public function test_unmanage_cohort_removes_members() {
94+
public function test_unmanage_cohort_removes_members(): void {
9595
global $DB;
9696

9797
$this->resetAfterTest();

tests/condition_manager_test.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3030
* @covers \tool_dynamic_cohorts\condition_manager
3131
*/
32-
class condition_manager_test extends \advanced_testcase {
32+
final class condition_manager_test extends \advanced_testcase {
3333

3434
/**
3535
* Test all conditions.
3636
*/
37-
public function test_get_all_conditions() {
37+
public function test_get_all_conditions(): void {
3838
$conditions = condition_manager::get_all_conditions();
3939
$this->assertIsArray($conditions);
4040
$this->assertNotEmpty($conditions);
@@ -49,7 +49,7 @@ public function test_get_all_conditions() {
4949
/**
5050
* Test processing condition form
5151
*/
52-
public function test_process_form() {
52+
public function test_process_form(): void {
5353
global $DB;
5454

5555
$this->resetAfterTest();
@@ -165,7 +165,7 @@ public function test_process_form() {
165165
/**
166166
* Test delete_conditions.
167167
*/
168-
public function test_delete_conditions() {
168+
public function test_delete_conditions(): void {
169169
global $DB;
170170

171171
$this->resetAfterTest();
@@ -200,7 +200,7 @@ public function test_delete_conditions() {
200200
/**
201201
* Test getting conditions for a given event.
202202
*/
203-
public function test_get_conditions_with_event() {
203+
public function test_get_conditions_with_event(): void {
204204
$this->resetAfterTest();
205205

206206
$user = $this->getDataGenerator()->create_user();
@@ -215,7 +215,7 @@ public function test_get_conditions_with_event() {
215215
/**
216216
* Basic test of building SQL data.
217217
*/
218-
public function test_build_sql_data() {
218+
public function test_build_sql_data(): void {
219219
$this->resetAfterTest();
220220

221221
$this->getDataGenerator()->create_user(['username' => 'user1username']);
@@ -279,7 +279,7 @@ public function test_build_sql_data() {
279279
/**
280280
* Test that generated SQL should exclude deleted users.
281281
*/
282-
public function test_should_exclude_deleted_users() {
282+
public function test_should_exclude_deleted_users(): void {
283283
global $DB;
284284

285285
$this->resetAfterTest();

tests/external/matching_users_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
*
3535
* @covers \tool_dynamic_cohorts\external\matching_users
3636
*/
37-
class matching_users_test extends externallib_advanced_testcase {
37+
final class matching_users_test extends externallib_advanced_testcase {
3838

3939
/**
4040
* Test exception if rule is not exist.
4141
*/
42-
public function test_get_total_throws_exception_on_invalid_rule() {
42+
public function test_get_total_throws_exception_on_invalid_rule(): void {
4343
$this->resetAfterTest();
4444

4545
$this->setAdminUser();
@@ -52,7 +52,7 @@ public function test_get_total_throws_exception_on_invalid_rule() {
5252
/**
5353
* Test required permissions.
5454
*/
55-
public function test_get_total_permissions() {
55+
public function test_get_total_permissions(): void {
5656
$this->resetAfterTest();
5757
$user = $this->getDataGenerator()->create_user();
5858
$this->setUser($user);
@@ -66,7 +66,7 @@ public function test_get_total_permissions() {
6666
/**
6767
* Test can get total.
6868
*/
69-
public function test_get_total_empty() {
69+
public function test_get_total_empty(): void {
7070
$this->resetAfterTest();
7171
$this->setAdminUser();
7272

@@ -79,7 +79,7 @@ public function test_get_total_empty() {
7979
/**
8080
* Test can get total.
8181
*/
82-
public function test_get_total() {
82+
public function test_get_total(): void {
8383
$this->resetAfterTest();
8484

8585
$this->setAdminUser();

tests/external/rule_conditions_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
*
3737
* @covers \tool_dynamic_cohorts\external\rule_conditions
3838
*/
39-
class rule_conditions_test extends externallib_advanced_testcase {
39+
final class rule_conditions_test extends externallib_advanced_testcase {
4040

4141
/**
4242
* Test exception if rule is not exist.
4343
*/
44-
public function test_get_conditions_throws_exception_on_invalid_rule() {
44+
public function test_get_conditions_throws_exception_on_invalid_rule(): void {
4545
$this->resetAfterTest();
4646

4747
$this->setAdminUser();
@@ -54,7 +54,7 @@ public function test_get_conditions_throws_exception_on_invalid_rule() {
5454
/**
5555
* Test required permissions.
5656
*/
57-
public function test_get_total_permissions() {
57+
public function test_get_total_permissions(): void {
5858
$this->resetAfterTest();
5959
$user = $this->getDataGenerator()->create_user();
6060
$this->setUser($user);
@@ -68,7 +68,7 @@ public function test_get_total_permissions() {
6868
/**
6969
* Test getting conditions for empty rule.
7070
*/
71-
public function test_get_conditions_for_empty_rule() {
71+
public function test_get_conditions_for_empty_rule(): void {
7272
$this->resetAfterTest();
7373
$this->setAdminUser();
7474

@@ -83,7 +83,7 @@ public function test_get_conditions_for_empty_rule() {
8383
/**
8484
* Test getting conditions for aa rule.
8585
*/
86-
public function test_get_conditions_for_rule() {
86+
public function test_get_conditions_for_rule(): void {
8787
$this->resetAfterTest();
8888
$this->setAdminUser();
8989

0 commit comments

Comments
 (0)