Skip to content

Commit

Permalink
code checker fixes (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syxton authored Jan 23, 2024
1 parent 8e854f4 commit dbd697a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
'request' => $massactionrequest,
'instance_id' => $instanceid,
'return_url' => $returnurl,
'sourcecourseid' => $context->instanceid
'sourcecourseid' => $context->instanceid,
];

$courseselectform = new course_select_form(null, $options);
Expand Down
19 changes: 10 additions & 9 deletions block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,16 @@ public function get_content(): stdClass {
}

$this->content->text = $OUTPUT->render_from_template('block_massaction/block_massaction',
['actions' => $actions, 'formaction' => $CFG->wwwroot . '/blocks/massaction/action.php',
'instanceid' => $this->instance->id, 'requesturi' => $_SERVER['REQUEST_URI'],
'helpicon' => $OUTPUT->help_icon('usage', 'block_massaction'),
'show_moveto_select' => (has_capability('moodle/course:manageactivities', $context)
&& has_capability('block/massaction:movetosection', $context)),
'show_duplicateto_select' => (has_capability('moodle/backup:backuptargetimport', $context) &&
has_capability('moodle/restore:restoretargetimport', $context)
&& has_capability('block/massaction:movetosection', $context)),
'sectionselecthelpicon' => $OUTPUT->help_icon('sectionselect', 'block_massaction')
['actions' => $actions,
'formaction' => $CFG->wwwroot . '/blocks/massaction/action.php',
'instanceid' => $this->instance->id, 'requesturi' => $_SERVER['REQUEST_URI'],
'helpicon' => $OUTPUT->help_icon('usage', 'block_massaction'),
'show_moveto_select' => (has_capability('moodle/course:manageactivities', $context) &&
has_capability('block/massaction:movetosection', $context)),
'show_duplicateto_select' => (has_capability('moodle/backup:backuptargetimport', $context) &&
has_capability('moodle/restore:restoretargetimport', $context) &&
has_capability('block/massaction:movetosection', $context)),
'sectionselecthelpicon' => $OUTPUT->help_icon('sectionselect', 'block_massaction'),
]);
}
return $this->content;
Expand Down
12 changes: 6 additions & 6 deletions classes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function duplicate(array $modules, $sectionnumber = false): void {
$section = $modinfo->get_section_info($duplicatedmod->sectionnum);
} else { // Duplicate to a specific section.
// Verify target.
if (!$section = $DB->get_record('course_sections', array('course' => $courseid, 'section' => $sectionnumber))) {
if (!$section = $DB->get_record('course_sections', ['course' => $courseid, 'section' => $sectionnumber])) {
throw new moodle_exception('sectionnotexist', 'block_massaction');
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid,

// Update course format setting to prevent new orphaned sections.
if (isset($targetformatopt['numsections'])) {
update_course((object)array('id' => $targetcourseid, 'numsections' => $targetformatopt['numsections'] + 1));
update_course((object)['id' => $targetcourseid, 'numsections' => $targetformatopt['numsections'] + 1]);
}

// Make sure new sectionnum is set accurately.
Expand All @@ -285,7 +285,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid,
// Update course format setting to prevent orphaned sections.
$targetformatopt = $targetformat->get_format_options();
if (isset($targetformatopt['numsections']) && $targetformatopt['numsections'] < $srcmaxsectionnum) {
update_course((object)array('id' => $targetcourseid, 'numsections' => $srcmaxsectionnum));
update_course((object)['id' => $targetcourseid, 'numsections' => $srcmaxsectionnum]);
}
}

Expand Down Expand Up @@ -414,7 +414,7 @@ public static function print_deletion_confirmation(array $modules, string $massa
'instance_id' => $instanceid,
'return_url' => $returnurl,
'request' => $massactionrequest,
'del_confirm' => 1
'del_confirm' => 1,
];
$optionsoncancel = ['id' => $cm->course];

Expand Down Expand Up @@ -460,7 +460,7 @@ public static function perform_deletion(array $modules): void {
new moodle_exception('invalidcoursemodule');
}

if (!$DB->get_record('course', array('id' => $cm->course))) {
if (!$DB->get_record('course', ['id' => $cm->course])) {
throw new moodle_exception('invalidcourseid');
}

Expand Down Expand Up @@ -573,7 +573,7 @@ public static function perform_moveto(array $modules, int $target): void {
}

// Verify target.
if (!$section = $DB->get_record('course_sections', array('course' => $cm->course, 'section' => $target))) {
if (!$section = $DB->get_record('course_sections', ['course' => $cm->course, 'section' => $target])) {
throw new moodle_exception('sectionnotexist', 'block_massaction');
}

Expand Down
20 changes: 10 additions & 10 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/site:manageblocks'
'clonepermissionsfrom' => 'moodle/site:manageblocks',
],

'block/massaction:activityshowhide' => [
Expand All @@ -54,7 +54,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:duplicate' => [
Expand All @@ -65,7 +65,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:duplicatetocourse' => [
Expand All @@ -76,7 +76,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:delete' => [
Expand All @@ -87,7 +87,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:indent' => [
Expand All @@ -98,7 +98,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:descriptionshowhide' => [
Expand All @@ -109,7 +109,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:sendcontentchangednotifications' => [
Expand All @@ -120,7 +120,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],

'block/massaction:movetosection' => [
Expand All @@ -131,6 +131,6 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities'
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],
];
4 changes: 2 additions & 2 deletions templates/block_massaction.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<button class="btn btn-link btn-sm" id="block-massaction-control-selectall">
{{#str}} selectall, block_massaction {{/str}}
</button>
<br/>
<br>
<div class="d-flex flex-row">
<div class="block-massaction-select-containing-div flex-grow-1">
{{> block_massaction/section_select}}
Expand All @@ -52,7 +52,7 @@
</div>
<button class="btn btn-link btn-sm" id="block-massaction-control-deselectall">
{{#str}} deselectall, block_massaction {{/str}}
</button><br/><br/>
</button><br><br>

{{#str}} withselected, block_massaction {{/str}}:
{{/actions.0.action}}
Expand Down
2 changes: 1 addition & 1 deletion tests/massaction_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setUp(): void {
// Generate two modules of each type for each of the 5 sections, so we have 6 modules per section.
$modulerecord = [
'course' => $this->course->id,
'showdescription' => 0
'showdescription' => 0,
];
for ($i = 0; $i < 10; $i++) {
$generator->create_module('assign', $modulerecord, ['section' => floor($i / 2)]);
Expand Down

0 comments on commit dbd697a

Please sign in to comment.