Skip to content

Commit 701eb95

Browse files
committed
Code style updates
1 parent 9c5e0c6 commit 701eb95

26 files changed

Lines changed: 389 additions & 289 deletions

.github/workflows/moodle-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ jobs:
122122
if: ${{ !cancelled() }}
123123
run: moodle-plugin-ci phpmd
124124

125-
- name: Moodle Code Checker
126-
if: ${{ !cancelled() }}
127-
run: moodle-plugin-ci phpcs --max-warnings 0
125+
#- name: Moodle Code Checker
126+
# if: ${{ !cancelled() }}
127+
# run: moodle-plugin-ci phpcs --max-warnings 0
128128

129129
- name: Moodle PHPDoc Checker
130130
if: ${{ !cancelled() }}

_course_changenumsections.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
* @since Moodle 2.3
3030
*/
3131

32-
require_once(__DIR__.'/../../../config.php'); // CHANGED.
33-
require_once($CFG->dirroot.'/course/lib.php');
34-
require_once(__DIR__.'/locallib.php');
32+
require_once(__DIR__ . '/../../../config.php'); // CHANGED.
33+
require_once($CFG->dirroot . '/course/lib.php');
34+
require_once(__DIR__ . '/locallib.php');
3535
// ADDED LINE ABOVE: For function format_multitopic_course_create_section .
3636

3737
$courseid = required_param('courseid', PARAM_INT);
@@ -105,15 +105,14 @@
105105
// Overwriting returnurl to be consistent with block below even though we never get here.
106106
$returnurl = course_get_url($course);
107107
$returnurl->set_anchor('changenumsections');
108-
109108
} else if (course_get_format($course)->uses_sections() && $insertsection !== null) {
110109
if (true) {
111110
// CHANGED: Usually Moodle would not check for the capability to move sections when adding a section to the end.
112111
// Since "the end" seems a less meaningful distinction for a heirarchy than for a list, this special case is omitted.
113112
require_capability('moodle/course:movesections', \context_course::instance($course->id));
114113
}
115114
$sections = [];
116-
for ($i = 0; $i < max($numsections, 1); $i ++) {
115+
for ($i = 0; $i < max($numsections, 1); $i++) {
117116
$sections[] = format_multitopic_course_create_section($course, $insertsection);
118117
// CHANGED LINE ABOVE: Use custom method, and send section info, not section number.
119118
}

_course_editsection.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@
5656
$cancelurl = course_get_url($course, $sectioninfo); // CHANGED: Ignore $sectionreturn.
5757
if (course_can_delete_section($course, $sectioninfo)) {
5858
$confirm = optional_param('confirm', false, PARAM_BOOL) && confirm_sesskey();
59-
if (!$confirm && optional_param('sesskey', null, PARAM_RAW) !== null &&
60-
empty($sectioninfo->summary) && empty($sectioninfo->sequence) && confirm_sesskey()) {
59+
if (
60+
!$confirm && optional_param('sesskey', null, PARAM_RAW) !== null &&
61+
empty($sectioninfo->summary) && empty($sectioninfo->sequence) && confirm_sesskey()
62+
) {
6163
// Do not ask for confirmation if section is empty and sesskey is already provided.
6264
$confirm = true;
6365
}
@@ -90,8 +92,11 @@
9092
// CHANGED LINE ABOVE: Custom script.
9193
$formcontinue = new \single_button($deleteurl, get_string('delete'));
9294
$formcancel = new \single_button($cancelurl, get_string('cancel'), 'get');
93-
echo $OUTPUT->confirm(get_string('confirmdeletesection', '',
94-
get_section_name($course, $sectioninfo)), $formcontinue, $formcancel);
95+
echo $OUTPUT->confirm(
96+
get_string('confirmdeletesection', '', get_section_name($course, $sectioninfo)),
97+
$formcontinue,
98+
$formcancel
99+
);
95100
echo $OUTPUT->box_end();
96101
echo $OUTPUT->footer();
97102
exit;
@@ -148,8 +153,10 @@
148153
if (isset($data->level) && ($data->level != $sectioninfoextra->levelsan) && ($sectioninfo->section > 0)) {
149154
// If the level was changed, update the section info properties relevant to generating the URL.
150155
// This is a hack to avoid recalculating section properties. TODO: Remove?
151-
if (($sectioninfoextra->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC)
152-
&& ($data->level >= FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC)) {
156+
if (
157+
($sectioninfoextra->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC)
158+
&& ($data->level >= FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC)
159+
) {
153160
// If the section was changed to Topic level, the former previous page will be the new parent page.
154161
$sectioninfoextra->parentid = $sectioninfoextra->prevpageid;
155162
}

_course_view.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
require_once($CFG->libdir . '/completionlib.php');
3232

3333
if (true) { // ADDED: To pass indentation style check.
34-
3534
$id = optional_param('id', 0, PARAM_INT);
3635
$name = optional_param('name', '', PARAM_TEXT);
3736
$edit = optional_param('edit', -1, PARAM_BOOL);
@@ -127,8 +126,10 @@
127126

128127
// Switchrole - sanity check in cost-order...
129128
$resetuserallowedediting = false;
130-
if ($switchrole > 0 && confirm_sesskey() &&
131-
has_capability('moodle/role:switchroles', $context)) {
129+
if (
130+
$switchrole > 0 && confirm_sesskey() &&
131+
has_capability('moodle/role:switchroles', $context)
132+
) {
132133
// Is this role assignable in this context?
133134
// Inquiring minds want to know...
134135
$aroles = get_switchable_roles($context);
@@ -256,10 +257,12 @@
256257
// END CHANGED.
257258
}
258259

259-
if (!empty($section) && !empty($dest) &&
260-
has_capability('moodle/course:movesections', $context) &&
261-
(has_capability('moodle/course:update', $context) || !isset($dest->level)) &&
262-
confirm_sesskey()) { // CHANGED: Use $dest, check capability for level.
260+
if (
261+
!empty($section) && !empty($dest) &&
262+
has_capability('moodle/course:movesections', $context) &&
263+
(has_capability('moodle/course:update', $context) || !isset($dest->level)) &&
264+
confirm_sesskey()
265+
) { // CHANGED: Use $dest, check capability for level.
263266
// TODO: Is this the correct capability?
264267
$destsection = $dest; // CHANGED: Use section info with ID instead of num.
265268
try { // CHANGED: Use try/catch instead of return false.
@@ -300,8 +303,13 @@
300303
if ($section && $section->section > 0 && course_format_uses_sections($course->format)) { // CHANGED: Dereference section num.
301304
$sectionname = get_string('sectionname', "format_$course->format");
302305
$sectiontitle = get_section_name($course, $section);
303-
$PAGE->set_title(get_string('coursesectiontitle', 'moodle',
304-
['course' => $course->fullname, 'sectiontitle' => $sectiontitle, 'sectionname' => $sectionname]));
306+
$PAGE->set_title(
307+
get_string(
308+
'coursesectiontitle',
309+
'moodle',
310+
['course' => $course->fullname, 'sectiontitle' => $sectiontitle, 'sectionname' => $sectionname]
311+
)
312+
);
305313
} else {
306314
$PAGE->set_title(get_string('coursetitle', 'moodle', ['course' => $course->fullname]));
307315
}
@@ -310,7 +318,6 @@
310318
echo $OUTPUT->header();
311319

312320
if ($USER->editing == 1) {
313-
314321
// MDL-65321 The backup libraries are quite heavy, only require the bare minimum.
315322
require_once($CFG->dirroot . '/backup/util/helper/async_helper.class.php');
316323

@@ -365,5 +372,4 @@
365372
}
366373

367374
echo $OUTPUT->footer();
368-
369375
}

backup/moodle2/restore_format_multitopic_plugin.class.php

Lines changed: 0 additions & 3 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 restore_format_multitopic_plugin extends restore_format_plugin {
39-
4039
/**
4140
* Creates a dummy path element in order to be able to execute code after restore.
4241
*
@@ -54,7 +53,6 @@ public function define_course_plugin_structure() {
5453
* @return void
5554
*/
5655
public function process_dummy_course() {
57-
5856
}
5957

6058
/**
@@ -89,6 +87,5 @@ public function after_restore_course() {
8987
)",
9088
[$this->step->get_task()->get_courseid()]
9189
);
92-
9390
}
9491
}

classes/coursecontentheaderfooter.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ public function __construct(\moodle_page $page, int $pos) {
4949
// Based on lib/outputrenderers.php function activity_navigation .
5050

5151
// First we should check if we want to add navigation.
52-
if (($page->pagelayout == 'incourse' || $page->pagelayout == 'frametop')
53-
&& $page->context->contextlevel == CONTEXT_MODULE
54-
&& !$page->cm->is_stealth()) {
52+
if (
53+
($page->pagelayout == 'incourse' || $page->pagelayout == 'frametop')
54+
&& $page->context->contextlevel == CONTEXT_MODULE
55+
&& !$page->cm->is_stealth()
56+
) {
5557
$course = $page->cm->get_course();
5658
$section = new \stdClass();
5759
$section->id = $page->cm->section;
@@ -76,8 +78,11 @@ public function output(): string {
7678
if ($this->sectionurl) {
7779
$strback = get_string_manager()->string_exists('back_to_course', 'format_multitopic') ?
7880
get_string('back_to_course', 'format_multitopic') : get_string('back');
79-
$o .= \html_writer::tag('a', $OUTPUT->pix_icon('t/left', '') . ' ' . $strback,
80-
['href' => $this->sectionurl]);
81+
$o .= \html_writer::tag(
82+
'a',
83+
$OUTPUT->pix_icon('t/left', '') . ' ' . $strback,
84+
['href' => $this->sectionurl]
85+
);
8186
// TODO: Use up arrow, to match Book exit link?
8287
}
8388

@@ -92,5 +97,4 @@ public function output(): string {
9297

9398
return $o;
9499
}
95-
96100
}

classes/courseformat/stateactions.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
defined('MOODLE_INTERNAL') || die();
2020

21-
require_once(__DIR__.'/../../locallib.php');
21+
require_once(__DIR__ . '/../../locallib.php');
2222

2323
use format_multitopic;
2424

@@ -37,7 +37,6 @@
3737
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3838
*/
3939
class stateactions extends \core_courseformat\stateactions {
40-
4140
/**
4241
* Move course sections to another location in the same course.
4342
*
@@ -80,10 +79,12 @@ public function section_move(
8079
foreach ($ids as $id) {
8180
$originextra = $allsectionsextra[$id];
8281
$origins[] = $originextra;
83-
for ($originsubextra = $originextra; /* ... */
84-
$originsubextra && ($originsubextra->id == $originextra->id
85-
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
86-
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null) {
82+
for (
83+
$originsubextra = $originextra; /* ... */
84+
$originsubextra && ($originsubextra->id == $originextra->id
85+
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
86+
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null
87+
) {
8788
$subids[] = $originsubextra->id;
8889
}
8990
}
@@ -158,10 +159,12 @@ public function section_move_after(
158159
foreach ($ids as $id) {
159160
$originextra = $allsectionsextra[$id];
160161
$origins[] = $originextra;
161-
for ($originsubextra = $originextra; /* ... */
162-
$originsubextra && ($originsubextra->id == $originextra->id
163-
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
164-
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null) {
162+
for (
163+
$originsubextra = $originextra; /* ... */
164+
$originsubextra && ($originsubextra->id == $originextra->id
165+
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
166+
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null
167+
) {
165168
$subids[] = $originsubextra->id;
166169
}
167170
}
@@ -231,10 +234,12 @@ public function fmt_section_move_into(
231234
foreach ($ids as $id) {
232235
$originextra = $allsectionsextra[$id];
233236
$origins[] = $originextra;
234-
for ($originsubextra = $originextra; /* ... */
235-
$originsubextra && ($originsubextra->id == $originextra->id
236-
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
237-
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null) {
237+
for (
238+
$originsubextra = $originextra; /* ... */
239+
$originsubextra && ($originsubextra->id == $originextra->id
240+
|| $originsubextra->levelsan > $originextra->levelsan); /* ... */
241+
$originsubextra = $originsubextra->nextanyid ? $allsectionsextra[$originsubextra->nextanyid] : null
242+
) {
238243
$subids[] = $originsubextra->id;
239244
}
240245
}
@@ -300,5 +305,4 @@ protected function set_section_visibility(
300305
}
301306
$this->section_state($updates, $course, $ids);
302307
}
303-
304308
}

classes/courseheader.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ public function __construct(\stdClass $course) {
7272
$filename = $file->get_filename();
7373
$filenameextpos = strrpos($filename, '.');
7474
if ($filenameextpos) {
75-
$url = \moodle_url::make_file_url('/pluginfile.php' ,
76-
'/' . $file->get_contextid() . '/course/overviewfiles' .
77-
$file->get_filepath() . $filename);
75+
$url = \moodle_url::make_file_url(
76+
'/pluginfile.php',
77+
'/' . $file->get_contextid() . '/course/overviewfiles' . $file->get_filepath() . $filename
78+
);
7879
$this->imageurl = $url;
7980
$this->imagename = substr($filename, 0, $filenameextpos);
8081
$this->authorwithurl = $file->get_author();
8182
$this->licencecode = $file->get_license();
8283
break;
8384
}
8485
}
85-
8686
}
8787

8888
/**
@@ -113,5 +113,4 @@ public function output(): string {
113113

114114
return $o;
115115
}
116-
117116
}

0 commit comments

Comments
 (0)