Skip to content

Commit 84db726

Browse files
committed
codecleaning with new codechecker version
1 parent 2d9fb93 commit 84db726

File tree

70 files changed

+1661
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1661
-947
lines changed

backup/moodle2/backup_ratingallocate_activity_stepslib.php

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3737
*/
3838
class backup_ratingallocate_activity_structure_step extends backup_activity_structure_step {
39-
4039
/**
4140
* Define the complete ratingallocate structure for backup.
4241
* @return backup_nested_element
@@ -51,41 +50,59 @@ protected function define_structure() {
5150

5251
// Define each element separated.
5352
$class = 'mod_ratingallocate\db\ratingallocate';
54-
$ratingallocate = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
55-
get_fields_for_tableClass($class));
53+
$ratingallocate = new backup_nested_element(
54+
get_tablename_for_tableClass($class),
55+
get_id_for_tableClass($class),
56+
get_fields_for_tableClass($class)
57+
);
5658

5759
$class = 'mod_ratingallocate\db\ratingallocate_choices';
5860
$ratingallocatechoices = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
59-
$ratingallocatechoice = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
60-
get_fields_for_tableClass($class));
61+
$ratingallocatechoice = new backup_nested_element(
62+
get_tablename_for_tableClass($class),
63+
get_id_for_tableClass($class),
64+
get_fields_for_tableClass($class)
65+
);
6166

6267
$class = 'mod_ratingallocate\db\ratingallocate_ratings';
6368
$ratingallocateratings = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
64-
$ratingallocaterating = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
65-
get_fields_for_tableClass($class));
69+
$ratingallocaterating = new backup_nested_element(
70+
get_tablename_for_tableClass($class),
71+
get_id_for_tableClass($class),
72+
get_fields_for_tableClass($class)
73+
);
6674

6775
$class = 'mod_ratingallocate\db\ratingallocate_allocations';
6876
$ratingallocateallocations = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
69-
$ratingallocateallocation = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
70-
get_fields_for_tableClass($class));
77+
$ratingallocateallocation = new backup_nested_element(
78+
get_tablename_for_tableClass($class),
79+
get_id_for_tableClass($class),
80+
get_fields_for_tableClass($class)
81+
);
7182

7283
$groupchoiceclass = 'mod_ratingallocate\db\ratingallocate_group_choices';
7384
$groupchoices = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass) . 's');
74-
$groupchoice = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass),
85+
$groupchoice = new backup_nested_element(
86+
get_tablename_for_tableClass($groupchoiceclass),
7587
get_id_for_tableClass($groupchoiceclass),
76-
get_fields_for_tableClass($groupchoiceclass));
88+
get_fields_for_tableClass($groupchoiceclass)
89+
);
7790

7891
$choicegroupclass = 'mod_ratingallocate\db\ratingallocate_ch_gengroups';
7992
$ratingallocatechoicegroups = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass) . 's');
80-
$ratingallocatechoicegroup = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass),
81-
get_id_for_tableClass($choicegroupclass),
82-
get_fields_for_tableClass($choicegroupclass));
93+
$ratingallocatechoicegroup = new backup_nested_element(
94+
get_tablename_for_tableClass($choicegroupclass),
95+
get_id_for_tableClass($choicegroupclass),
96+
get_fields_for_tableClass($choicegroupclass)
97+
);
8398

8499
$groupingclass = 'mod_ratingallocate\db\ratingallocate_groupings';
85100
$ratingallocategroupings = new backup_nested_element(get_tablename_for_tableClass($groupingclass) . 's');
86-
$ratingallocategrouping = new backup_nested_element(get_tablename_for_tableClass($groupingclass),
87-
get_id_for_tableClass($groupingclass),
88-
get_fields_for_tableClass($groupingclass));
101+
$ratingallocategrouping = new backup_nested_element(
102+
get_tablename_for_tableClass($groupingclass),
103+
get_id_for_tableClass($groupingclass),
104+
get_fields_for_tableClass($groupingclass)
105+
);
89106

90107
// Build the tree.
91108
$ratingallocate->add_child($ratingallocatechoices);
@@ -107,29 +124,41 @@ protected function define_structure() {
107124
$ratingallocatechoicegroups->add_child($ratingallocatechoicegroup);
108125

109126
// Define sources.
110-
$ratingallocate->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate'),
111-
[this_db\ratingallocate::ID => backup::VAR_ACTIVITYID], this_db\ratingallocate_choices::ID . ' ASC');
112-
$ratingallocatechoice->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_choices'),
113-
[this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID],
114-
this_db\ratingallocate_choices::ID . ' ASC');
127+
$ratingallocate->set_source_table(
128+
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate'),
129+
[this_db\ratingallocate::ID => backup::VAR_ACTIVITYID],
130+
this_db\ratingallocate_choices::ID . ' ASC'
131+
);
132+
$ratingallocatechoice->set_source_table(
133+
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_choices'),
134+
[this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID],
135+
this_db\ratingallocate_choices::ID . ' ASC'
136+
);
115137
$groupchoice->set_source_table(get_tablename_for_tableClass($groupchoiceclass), ['choiceid' => backup::VAR_PARENTID]);
116138
$ratingallocatechoicegroup->set_source_table(
117-
get_tablename_for_tableClass($choicegroupclass), ['choiceid' => backup::VAR_PARENTID]);
139+
get_tablename_for_tableClass($choicegroupclass),
140+
['choiceid' => backup::VAR_PARENTID]
141+
);
118142
$ratingallocategrouping->set_source_table(
119-
get_tablename_for_tableClass($groupingclass), ['ratingallocateid' => backup::VAR_PARENTID]);
143+
get_tablename_for_tableClass($groupingclass),
144+
['ratingallocateid' => backup::VAR_PARENTID]
145+
);
120146

121147
if ($userinfo) {
122-
$ratingallocaterating->set_source_table(get_tablename_for_tableClass(
123-
'mod_ratingallocate\db\ratingallocate_ratings'),
124-
[this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID],
125-
this_db\ratingallocate_ratings::ID . ' ASC');
148+
$ratingallocaterating->set_source_table(
149+
get_tablename_for_tableClass(
150+
'mod_ratingallocate\db\ratingallocate_ratings'
151+
),
152+
[this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID],
153+
this_db\ratingallocate_ratings::ID . ' ASC'
154+
);
126155
$ratingallocateallocation->set_source_table(
127-
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_allocations'),
128-
[
156+
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_allocations'),
157+
[
129158
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
130159
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID,
131160
],
132-
this_db\ratingallocate_allocations::ID . ' ASC'
161+
this_db\ratingallocate_allocations::ID . ' ASC'
133162
);
134163
}
135164

backup/moodle2/backup_ratingallocate_activity_task.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3030
*/
3131
class backup_ratingallocate_activity_task extends backup_activity_task {
32-
3332
/**
3433
* Define (add) particular settings this activity can have
3534
*/

backup/moodle2/restore_ratingallocate_activity_stepslib.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2525
*/
2626
class restore_ratingallocate_activity_structure_step extends restore_activity_structure_step {
27-
2827
/**
2928
* Define the complete ratingallocate structure for restore.
3029
* @return mixed
@@ -39,18 +38,28 @@ protected function define_structure() {
3938
$choicespath =
4039
$ratingallocatepath . '/' . this_db\ratingallocate_choices::TABLE . 's/' . this_db\ratingallocate_choices::TABLE;
4140
$paths[] = new restore_path_element(this_db\ratingallocate_choices::TABLE, $choicespath);
42-
$paths[] = new restore_path_element(this_db\ratingallocate_group_choices::TABLE,
43-
$choicespath .'/' . this_db\ratingallocate_group_choices::TABLE .'s/' . this_db\ratingallocate_group_choices::TABLE);
44-
$paths[] = new restore_path_element(this_db\ratingallocate_ch_gengroups::TABLE,
45-
$choicespath .'/'. this_db\ratingallocate_ch_gengroups::TABLE . 's/' . this_db\ratingallocate_ch_gengroups::TABLE);
46-
$paths[] = new restore_path_element(this_db\ratingallocate_groupings::TABLE,
47-
$ratingallocatepath . '/' . this_db\ratingallocate_groupings::TABLE . 's/' . this_db\ratingallocate_groupings::TABLE);
41+
$paths[] = new restore_path_element(
42+
this_db\ratingallocate_group_choices::TABLE,
43+
$choicespath . '/' . this_db\ratingallocate_group_choices::TABLE . 's/' . this_db\ratingallocate_group_choices::TABLE
44+
);
45+
$paths[] = new restore_path_element(
46+
this_db\ratingallocate_ch_gengroups::TABLE,
47+
$choicespath . '/' . this_db\ratingallocate_ch_gengroups::TABLE . 's/' . this_db\ratingallocate_ch_gengroups::TABLE
48+
);
49+
$paths[] = new restore_path_element(
50+
this_db\ratingallocate_groupings::TABLE,
51+
$ratingallocatepath . '/' . this_db\ratingallocate_groupings::TABLE . 's/' . this_db\ratingallocate_groupings::TABLE
52+
);
4853
if ($userinfo) {
49-
$paths[] = new restore_path_element(this_db\ratingallocate_ratings::TABLE,
50-
$choicespath . '/' . this_db\ratingallocate_ratings::TABLE . 's/' . this_db\ratingallocate_ratings::TABLE);
51-
$paths[] = new restore_path_element(this_db\ratingallocate_allocations::TABLE,
52-
$choicespath . '/' . this_db\ratingallocate_allocations::TABLE . 's/' .
53-
this_db\ratingallocate_allocations::TABLE);
54+
$paths[] = new restore_path_element(
55+
this_db\ratingallocate_ratings::TABLE,
56+
$choicespath . '/' . this_db\ratingallocate_ratings::TABLE . 's/' . this_db\ratingallocate_ratings::TABLE
57+
);
58+
$paths[] = new restore_path_element(
59+
this_db\ratingallocate_allocations::TABLE,
60+
$choicespath . '/' . this_db\ratingallocate_allocations::TABLE . 's/' .
61+
this_db\ratingallocate_allocations::TABLE
62+
);
5463
}
5564

5665
// Return the paths wrapped into standard activity structure.

backup/moodle2/restore_ratingallocate_activity_task.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3636
*/
3737
class restore_ratingallocate_activity_task extends restore_activity_task {
38-
3938
/**
4039
* Define (add) particular settings this activity can have
4140
*/

classes/allocations_table.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* @package mod_ratingallocate
3636
*/
3737
class allocations_table extends \table_sql {
38-
3938
/**
4039
* @var ratingallocate
4140
*/
@@ -95,8 +94,10 @@ public function setup_table() {
9594
$headers[] = get_string('firstname');
9695
$columns[] = 'lastname';
9796
$headers[] = get_string('lastname');
98-
if (in_array('email', $additionalfields) &&
99-
has_capability('moodle/course:useremail', $this->ratingallocate->get_context())) {
97+
if (
98+
in_array('email', $additionalfields) &&
99+
has_capability('moodle/course:useremail', $this->ratingallocate->get_context())
100+
) {
100101
$columns[] = 'email';
101102
$headers[] = get_string('email');
102103
}
@@ -128,7 +129,7 @@ public function build_table_by_sql() {
128129
$data = $this->rawdata;
129130

130131
// Retrieve all users, who rated within the course.
131-
$userwithratingids = array_map(function($x) {
132+
$userwithratingids = array_map(function ($x) {
132133
return $x->userid;
133134
},
134135
$this->ratingallocate->get_users_with_ratings());
@@ -175,8 +176,9 @@ public function build_table_by_sql() {
175176
if (count($userwithrating) > 0 && ($this->currpage + 1) * $this->pagesize >= $this->totalrows) {
176177
$noallocation = new \stdClass();
177178
$noallocation->choicetitle = get_string(
178-
'allocations_table_noallocation',
179-
RATINGALLOCATE_MOD_NAME);
179+
'allocations_table_noallocation',
180+
RATINGALLOCATE_MOD_NAME
181+
);
180182

181183
foreach ($userwithrating as $userid => $user) {
182184
if (object_property_exists($noallocation, 'users')) {
@@ -210,8 +212,10 @@ private function get_user_link($user) {
210212
if ($COURSE->id == SITEID) {
211213
$profileurl = new \moodle_url('/user/profile.php', ['id' => $user->id]);
212214
} else {
213-
$profileurl = new \moodle_url('/user/view.php',
214-
['id' => $user->id, 'course' => $COURSE->id]);
215+
$profileurl = new \moodle_url(
216+
'/user/view.php',
217+
['id' => $user->id, 'course' => $COURSE->id]
218+
);
215219
}
216220
return \html_writer::link($profileurl, $name);
217221
}
@@ -241,5 +245,4 @@ public function init_sql() {
241245

242246
$this->query_db(20);
243247
}
244-
245248
}

classes/choice/ratingallocate_choice.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,4 @@ public function __set($name, $value) {
6767
public function __construct($record) {
6868
$this->dbrecord = $record;
6969
}
70-
7170
}

classes/choice_importer.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class choice_importer {
7676
* @param array $fields
7777
* @return void
7878
*/
79-
public static function print_fields($fields=self::REQUIRED_FIELDS) {
79+
public static function print_fields($fields = self::REQUIRED_FIELDS) {
8080
return '[' . join(', ', $fields) . ']';
8181
}
8282

@@ -137,12 +137,12 @@ public function free_reader() {
137137
* - rowcount: The number of being row processed. (Once finished, should add up to readcount.)
138138
* - importcount: The number of rows successfully processed.
139139
*/
140-
public function import($content, $live=true) {
140+
public function import($content, $live = true) {
141141
global $DB;
142142

143143
$reader = $this->get_reader();
144144

145-
$importstatus = new \stdClass;
145+
$importstatus = new \stdClass();
146146
$importstatus->status = self::IMPORT_STATUS_OK; // Unless we hear otherwise.
147147
$importstatus->live = $live; // Only commit live transactions.
148148
$importstatus->errors = [];
@@ -169,8 +169,11 @@ public function import($content, $live=true) {
169169
$missingfields = array_diff(self::REQUIRED_FIELDS, $fieldnames);
170170
if ($missingfields) {
171171
$importstatus->status = self::IMPORT_STATUS_SETUP_ERROR;
172-
$importstatus->errors[] = get_string('csvupload_missing_fields', 'ratingallocate',
173-
self::print_fields($missingfields));
172+
$importstatus->errors[] = get_string(
173+
'csvupload_missing_fields',
174+
'ratingallocate',
175+
self::print_fields($missingfields)
176+
);
174177
return $importstatus;
175178
}
176179

@@ -181,7 +184,6 @@ public function import($content, $live=true) {
181184
// Start DB transaction.
182185
$transaction = $this->ratingallocate->db->start_delegated_transaction();
183186
try {
184-
185187
$reader->init();
186188
while ($record = $reader->next()) {
187189
$importstatus->rowcount++;
@@ -200,8 +202,11 @@ public function import($content, $live=true) {
200202

201203
if ($fieldname === 'title' && mb_strlen($cell, 'UTF-8') > 255) {
202204
$importstatus->status = self::IMPORT_STATUS_DATA_ERROR;
203-
$importstatus->errors[] = get_string('csvupload_too_long_title',
204-
RATINGALLOCATE_MOD_NAME, $cell);
205+
$importstatus->errors[] = get_string(
206+
'csvupload_too_long_title',
207+
RATINGALLOCATE_MOD_NAME,
208+
$cell
209+
);
205210
$ischoiceimportable = false;
206211
}
207212

@@ -275,13 +280,11 @@ public function import($content, $live=true) {
275280
$transaction->allow_commit();
276281
}
277282
$transaction->dispose();
278-
279283
} catch (\Exception $e) {
280284
if (isset($transaction)) {
281285
$transaction->rollback($e);
282286
}
283287
}
284-
285288
}
286289
}
287290

@@ -296,11 +299,15 @@ public function import($content, $live=true) {
296299
}
297300
} else {
298301
if ($live) {
299-
$importstatus->status_message = get_string('csvupload_live_problems', 'ratingallocate',
302+
$importstatus->status_message = get_string(
303+
'csvupload_live_problems',
304+
'ratingallocate',
300305
count($importstatus->errors)
301306
);
302307
} else {
303-
$importstatus->status_message = get_string('csvupload_test_problems', 'ratingallocate',
308+
$importstatus->status_message = get_string(
309+
'csvupload_test_problems',
310+
'ratingallocate',
304311
count($importstatus->errors)
305312
);
306313
}
@@ -321,9 +328,10 @@ public function import($content, $live=true) {
321328
* @param int $max Maximum number of individual notifications to send.
322329
* @return void
323330
*/
324-
public function issue_notifications($errors,
325-
$notificationtype=\core\output\notification::NOTIFY_WARNING,
326-
$max=self::MAX_WARNING_COUNT
331+
public function issue_notifications(
332+
$errors,
333+
$notificationtype = \core\output\notification::NOTIFY_WARNING,
334+
$max = self::MAX_WARNING_COUNT
327335
) {
328336
$errorcount = count($errors);
329337

classes/completion/custom_completion.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class custom_completion extends activity_custom_completion {
35-
3635
/**
3736
* Fetches the completion state for a given completion rule.
3837
*
@@ -104,4 +103,3 @@ public function get_sort_order(): array {
104103
];
105104
}
106105
}
107-

0 commit comments

Comments
 (0)