Skip to content

Commit efdcfc1

Browse files
committed
Make codechecker happy again
1 parent 9b260de commit efdcfc1

File tree

5 files changed

+48
-26
lines changed

5 files changed

+48
-26
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changes
66

77
### Unreleased
88

9+
* 2025-10-15 - Make codechecker happy again
910
* 2025-10-15 - Tests: Switch Github actions workflows to reusable workflows by Moodle an Hochschulen e.V.
1011

1112
### v5.0-r1

classes/set_fields.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
defined('MOODLE_INTERNAL') || die();
2929

30-
require_once($CFG->dirroot.'/course/lib.php');
30+
require_once($CFG->dirroot . '/course/lib.php');
3131

3232
/**
3333
* Helper functions for tool_coursefields.
@@ -70,7 +70,10 @@ public static function maybe_alter_course_fields($course, $fields) {
7070
$fieldname = substr($key, 12);
7171

7272
// Continue if the corresponding checkbox element was not activated.
73-
if (!isset($fields->{'customfieldcheckbox_'.$fieldname}) || $fields->{'customfieldcheckbox_'.$fieldname} != true) {
73+
if (
74+
!isset($fields->{'customfieldcheckbox_' . $fieldname}) ||
75+
$fields->{'customfieldcheckbox_' . $fieldname} != true
76+
) {
7477
continue;
7578
}
7679

classes/set_fields_form.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,30 @@ public function definition() {
6464
// If we are dealing with a customfield_textarea fieldtype, the shortname needs special treatment.
6565
// For now, this special treatment is hardcoded.
6666
if ($field->get('type') == 'textarea') {
67-
$shortname = $shortname.'_editor';
67+
$shortname = $shortname . '_editor';
6868
}
6969

7070
// Get some more field metadata.
71-
$elementname = 'customfield_'.$shortname;
71+
$elementname = 'customfield_' . $shortname;
7272
$formattedname = $field->get_formatted_name();
7373

7474
// Add a header to help the user identify the following form element as a group.
75-
$headerelementname = 'customfieldheader_'.$shortname;
76-
$headerelement = $mform->createElement('static', $headerelementname, '<h4>'.$formattedname.'</h4>');
75+
$headerelementname = 'customfieldheader_' . $shortname;
76+
$headerelement = $mform->createElement('static', $headerelementname, '<h4>' . $formattedname . '</h4>');
7777
$mform->insertElementBefore($headerelement, $elementname);
7878

7979
// Add a checkbox element in front of the field to control if this value should be overwritten.
80-
$checkboxelementname = 'customfieldcheckbox_'.$shortname;
81-
$checkboxelement = $mform->createElement('advcheckbox', $checkboxelementname, '',
82-
get_string('overwritefield', 'tool_coursefields'));
80+
$checkboxelementname = 'customfieldcheckbox_' . $shortname;
81+
$checkboxelement = $mform->createElement(
82+
'advcheckbox',
83+
$checkboxelementname,
84+
'',
85+
get_string('overwritefield', 'tool_coursefields')
86+
);
8387
$mform->insertElementBefore($checkboxelement, $elementname);
8488

8589
// Add a static element in front of the field to inform the admin about the details of the field.
86-
$staticelementname = 'customfieldstatic_'.$shortname;
90+
$staticelementname = 'customfieldstatic_' . $shortname;
8791
$staticelementnotes = [];
8892
if ($field->get_configdata_property('required') == 1) {
8993
$staticelementnotes[] = get_string('fieldisrequired', 'tool_coursefields');
@@ -99,8 +103,18 @@ public function definition() {
99103
// Disable the field as long as the checkbox element is not activated.
100104
$mform->disabledIf($elementname, $checkboxelementname);
101105

102-
unset($shortname, $elementname, $formattedname, $headerelementname, $headerelement, $checkboxelementname,
103-
$checkboxelement, $staticelementname, $staticelementnotes, $staticelement);
106+
unset(
107+
$shortname,
108+
$elementname,
109+
$formattedname,
110+
$headerelementname,
111+
$headerelement,
112+
$checkboxelementname,
113+
$checkboxelement,
114+
$staticelementname,
115+
$staticelementnotes,
116+
$staticelement
117+
);
104118
}
105119

106120
// Get rid of any required rules in this form as these won't validate correctly with the checkbox elements.

index.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
$returnurl = new \core\url('/course/management.php', ['categoryid' => $categoryid]);
3636

3737
// Current location.
38-
$url = new \core\url('/'.$CFG->admin.'/tool/coursefields/index.php',
38+
$url = new \core\url(
39+
'/' . $CFG->admin . '/tool/coursefields/index.php',
3940
[
4041
'category' => $categoryid,
4142
]
@@ -45,7 +46,7 @@
4546
$PAGE->set_context($context);
4647
$PAGE->set_pagelayout('admin');
4748
$PAGE->set_url($url);
48-
$PAGE->set_title(get_string('coursecatmanagement') . ': '. get_string('setfields', 'tool_coursefields'));
49+
$PAGE->set_title(get_string('coursecatmanagement') . ': ' . get_string('setfields', 'tool_coursefields'));
4950
$PAGE->set_heading($SITE->fullname);
5051

5152
// Create form.
@@ -62,8 +63,11 @@
6263
]
6364
);
6465
\core\task\manager::queue_adhoc_task($task);
65-
redirect($returnurl, get_string('updatequeued', 'tool_coursefields',
66-
format_string($category->name, true, ['context' => $context])));
66+
redirect($returnurl, get_string(
67+
'updatequeued',
68+
'tool_coursefields',
69+
format_string($category->name, true, ['context' => $context])
70+
));
6771
} else {
6872
// Prepare the form.
6973
$mform->set_data(['category' => $categoryid]);

lib.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ function tool_coursefields_extend_navigation_category_settings($navigation, $con
4646
$navigation->add_node(
4747
navigation_node::create(
4848
get_string('setfields', 'tool_coursefields'),
49-
new \core\url(
50-
'/'.$CFG->admin.'/tool/coursefields/index.php',
51-
['category' => $context->instanceid]
52-
),
53-
navigation_node::TYPE_SETTING,
54-
null,
55-
null,
56-
new \core\output\pix_icon('i/settings', '')
57-
)
58-
);
49+
new \core\url(
50+
'/' . $CFG->admin . '/tool/coursefields/index.php',
51+
['category' => $context->instanceid]
52+
),
53+
navigation_node::TYPE_SETTING,
54+
null,
55+
null,
56+
new \core\output\pix_icon('i/settings', '')
57+
)
58+
);
5959
}
6060
}

0 commit comments

Comments
 (0)