From 4e8417dcea76ef9ff2d668929dbcc66938a69c79 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Sun, 15 Oct 2023 10:07:42 +0200 Subject: [PATCH] Coding style --- .../restore_learningmap_activity_task.class.php | 4 ++-- classes/completion/custom_completion.php | 6 +++--- classes/external/get_dependingmodules.php | 6 +++--- classes/external/get_learningmap.php | 6 +++--- db/access.php | 8 ++++---- db/events.php | 6 +++--- db/services.php | 2 +- lib.php | 2 +- mod_form.php | 8 ++++---- tests/generator/lib.php | 2 +- tests/mod_learningmap_completion_test.php | 8 ++++---- tests/mod_learningmap_generation_test.php | 2 +- tests/mod_learningmap_mapworker_test.php | 12 ++++++------ 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/backup/moodle2/restore_learningmap_activity_task.class.php b/backup/moodle2/restore_learningmap_activity_task.class.php index 272e8c0..5c07087 100644 --- a/backup/moodle2/restore_learningmap_activity_task.class.php +++ b/backup/moodle2/restore_learningmap_activity_task.class.php @@ -54,7 +54,7 @@ protected function define_my_steps() : void { */ public static function define_decode_contents() : array { $contents = []; - $contents[] = new restore_decode_content('learningmap', array('intro'), 'learningmap'); + $contents[] = new restore_decode_content('learningmap', ['intro'], 'learningmap'); return $contents; } @@ -78,7 +78,7 @@ public function after_restore() : void { $courseid = $this->get_courseid(); $modinfo = get_fast_modinfo($courseid); - $item = $DB->get_record('learningmap', array('id' => $this->get_activityid()), '*', MUST_EXIST); + $item = $DB->get_record('learningmap', ['id' => $this->get_activityid()], '*', MUST_EXIST); $placestore = json_decode($item->placestore); diff --git a/classes/completion/custom_completion.php b/classes/completion/custom_completion.php index a1b6ac4..6b1f4c9 100644 --- a/classes/completion/custom_completion.php +++ b/classes/completion/custom_completion.php @@ -143,7 +143,7 @@ public static function get_defined_custom_rules(): array { return [ 'completion_with_one_target', 'completion_with_all_targets', - 'completion_with_all_places' + 'completion_with_all_places', ]; } @@ -156,7 +156,7 @@ public function get_custom_rule_descriptions(): array { return [ 'completion_with_one_target' => get_string('completiondetail:one_target', 'learningmap'), 'completion_with_all_targets' => get_string('completiondetail:all_targets', 'learningmap'), - 'completion_with_all_places' => get_string('completiondetail:all_places', 'learningmap') + 'completion_with_all_places' => get_string('completiondetail:all_places', 'learningmap'), ]; } @@ -170,7 +170,7 @@ public function get_sort_order(): array { 'completionview', 'completion_with_one_target', 'completion_with_all_targets', - 'completion_with_all_places' + 'completion_with_all_places', ]; } } diff --git a/classes/external/get_dependingmodules.php b/classes/external/get_dependingmodules.php index 4ece72f..267a059 100644 --- a/classes/external/get_dependingmodules.php +++ b/classes/external/get_dependingmodules.php @@ -57,7 +57,7 @@ class get_dependingmodules extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'cmId' => new external_value(PARAM_INT, 'Course module ID of the learningmap')]); + 'cmId' => new external_value(PARAM_INT, 'Course module ID of the learningmap'), ]); } /** @@ -71,7 +71,7 @@ public static function execute_returns(): external_single_structure { [ 'dependingModuleIds' => new external_multiple_structure( new external_value(PARAM_INT, 'depending course module ids') - ) + ), ] ); } @@ -95,7 +95,7 @@ public static function execute(int $cmid): array { self::validate_context($context); require_capability('mod/learningmap:view', $context); return [ - 'dependingModuleIds' => learningmap_get_place_cm($cminfo) + 'dependingModuleIds' => learningmap_get_place_cm($cminfo), ]; } } diff --git a/classes/external/get_learningmap.php b/classes/external/get_learningmap.php index b18abfc..e1ac698 100644 --- a/classes/external/get_learningmap.php +++ b/classes/external/get_learningmap.php @@ -56,7 +56,7 @@ class get_learningmap extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'cmId' => new external_value(PARAM_INT, 'Course module ID of the learningmap') + 'cmId' => new external_value(PARAM_INT, 'Course module ID of the learningmap'), ]); } @@ -69,7 +69,7 @@ public static function execute_returns(): external_single_structure { return new external_single_structure( [ - 'content' => new external_value(PARAM_RAW, 'Rendered learningmap') + 'content' => new external_value(PARAM_RAW, 'Rendered learningmap'), ] ); } @@ -95,7 +95,7 @@ public static function execute(int $cmid): array { $completion = new \completion_info($course); $completion->set_module_viewed($cminfo); return [ - 'content' => learningmap_get_learningmap($cminfo) + 'content' => learningmap_get_learningmap($cminfo), ]; } } diff --git a/db/access.php b/db/access.php index 0925efb..0b578a3 100644 --- a/db/access.php +++ b/db/access.php @@ -33,9 +33,9 @@ 'contextlevel' => CONTEXT_COURSE, 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'mod/learningmap:view' => [ @@ -45,7 +45,7 @@ 'user' => CAP_ALLOW, 'guest' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ] + 'manager' => CAP_ALLOW, + ], ], ]; diff --git a/db/events.php b/db/events.php index 17374f6..27abb0e 100644 --- a/db/events.php +++ b/db/events.php @@ -28,10 +28,10 @@ $observers = [ [ 'eventname' => '\core\event\course_module_completion_updated', - 'callback' => '\mod_learningmap\autoupdate::update_from_event' + 'callback' => '\mod_learningmap\autoupdate::update_from_event', ], [ 'eventname' => '\core\event\course_module_deleted', - 'callback' => '\mod_learningmap\autoupdate::update_from_delete_event' - ] + 'callback' => '\mod_learningmap\autoupdate::update_from_delete_event', + ], ]; diff --git a/db/services.php b/db/services.php index 6b2a78c..2ac2809 100644 --- a/db/services.php +++ b/db/services.php @@ -41,5 +41,5 @@ 'type' => 'read', 'ajax' => true, 'capabilities' => 'mod/learningmap:view', - ] + ], ]; diff --git a/lib.php b/lib.php index 7fdb508..86cb536 100644 --- a/lib.php +++ b/lib.php @@ -171,7 +171,7 @@ function learningmap_get_coursemodule_info($cm) : cached_cm_info { 'nocompletion', 'completion_with_one_target', 'completion_with_all_targets', - 'completion_with_all_places' + 'completion_with_all_places', ]; if ($cm->completion == COMPLETION_TRACKING_AUTOMATIC && $map->completiontype > 0) { diff --git a/mod_form.php b/mod_form.php index f99eeb6..6839be2 100644 --- a/mod_form.php +++ b/mod_form.php @@ -61,7 +61,7 @@ public function definition() : void { 'id' => $cmid, 'name' => $module->name, 'completionenabled' => $module->completion > 0, - 'hidden' => $module->visible == 0 + 'hidden' => $module->visible == 0, ]; } } @@ -88,7 +88,7 @@ public function definition() : void { 'name' => $feature, 'title' => get_string($feature, 'learningmap'), 'text' => get_string($feature . '_help', 'learningmap'), - 'alt' => get_string('help') + 'alt' => get_string('help'), ]; } $mform->addElement( @@ -115,7 +115,7 @@ public function definition() : void { [ 'accepted_types' => 'web_image', 'maxfiles' => 1, - 'subdirs' => 0 + 'subdirs' => 0, ] ); $mform->addRule('introeditor[itemid]', null, 'required', null, 'client'); @@ -175,7 +175,7 @@ public function add_completion_rules() : array { LEARNINGMAP_NOCOMPLETION => get_string('nocompletion', 'learningmap'), LEARNINGMAP_COMPLETION_WITH_ONE_TARGET => get_string('completion_with_one_target', 'learningmap'), LEARNINGMAP_COMPLETION_WITH_ALL_TARGETS => get_string('completion_with_all_targets', 'learningmap'), - LEARNINGMAP_COMPLETION_WITH_ALL_PLACES => get_string('completion_with_all_places', 'mod_learningmap') + LEARNINGMAP_COMPLETION_WITH_ALL_PLACES => get_string('completion_with_all_places', 'mod_learningmap'), ]; $mform->addElement( diff --git a/tests/generator/lib.php b/tests/generator/lib.php index cfc81ea..cb1e668 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -40,7 +40,7 @@ public function create_instance($record = null, array $options = null) : stdClas 'intro' => file_get_contents($CFG->dirroot . '/mod/learningmap/tests/generator/test.svg'), 'introformat' => 1, 'placestore' => file_get_contents($CFG->dirroot . '/mod/learningmap/tests/generator/test.json'), - 'completiontype' => 2 + 'completiontype' => 2, ]; return parent::create_instance($record, (array)$options); diff --git a/tests/mod_learningmap_completion_test.php b/tests/mod_learningmap_completion_test.php index 79ef4a6..7a8cb7b 100644 --- a/tests/mod_learningmap_completion_test.php +++ b/tests/mod_learningmap_completion_test.php @@ -99,7 +99,7 @@ public function prepare($completiontype, $groupmode = false): void { $this->course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]); $this->learningmap = $this->getDataGenerator()->create_module('learningmap', ['course' => $this->course, 'completion' => 2, 'completiontype' => $completiontype, - 'groupmode' => ($groupmode ? SEPARATEGROUPS : NOGROUPS)] + 'groupmode' => ($groupmode ? SEPARATEGROUPS : NOGROUPS), ] ); $this->activities = []; @@ -115,7 +115,7 @@ public function prepare($completiontype, $groupmode = false): void { $this->users[0] = $this->getDataGenerator()->create_user( [ 'email' => 'user1@example.com', - 'username' => 'user1' + 'username' => 'user1', ] ); $studentrole = $DB->get_record('role', ['shortname' => 'student']); @@ -125,13 +125,13 @@ public function prepare($completiontype, $groupmode = false): void { $this->users[1] = $this->getDataGenerator()->create_user( [ 'email' => 'user2@example.com', - 'username' => 'user2' + 'username' => 'user2', ] ); $this->users[2] = $this->getDataGenerator()->create_user( [ 'email' => 'user3@example.com', - 'username' => 'user3' + 'username' => 'user3', ] ); $this->getDataGenerator()->enrol_user($this->users[1]->id, $this->course->id, $studentrole->id); diff --git a/tests/mod_learningmap_generation_test.php b/tests/mod_learningmap_generation_test.php index efa0e1c..9a3f033 100644 --- a/tests/mod_learningmap_generation_test.php +++ b/tests/mod_learningmap_generation_test.php @@ -39,7 +39,7 @@ public function test_create_instance() : void { $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); - $this->assertFalse($DB->record_exists('learningmap', array('course' => $course->id))); + $this->assertFalse($DB->record_exists('learningmap', ['course' => $course->id])); $learningmap = $this->getDataGenerator()->create_module('learningmap', ['course' => $course]); $records = $DB->get_records('learningmap', ['course' => $course->id], 'id'); diff --git a/tests/mod_learningmap_mapworker_test.php b/tests/mod_learningmap_mapworker_test.php index 9a542e6..2df68af 100644 --- a/tests/mod_learningmap_mapworker_test.php +++ b/tests/mod_learningmap_mapworker_test.php @@ -79,7 +79,7 @@ public function setUp(): void { $this->learningmap = $this->getDataGenerator()->create_module('learningmap', [ 'course' => $this->course, 'completion' => COMPLETION_TRACKING_AUTOMATIC, - 'completiontype' => LEARNINGMAP_NOCOMPLETION + 'completiontype' => LEARNINGMAP_NOCOMPLETION, ]); $this->activities = []; @@ -91,7 +91,7 @@ public function setUp(): void { 'content' => 'B', 'course' => $this->course, 'completion' => COMPLETION_TRACKING_AUTOMATIC, - 'completionview' => COMPLETION_VIEW_REQUIRED + 'completionview' => COMPLETION_VIEW_REQUIRED, ] ); // The JSON contains spare course module IDs 9999x, replacing them by the real course module IDs here. @@ -102,7 +102,7 @@ public function setUp(): void { $this->user1 = $this->getDataGenerator()->create_user( [ 'email' => 'user1@example.com', - 'username' => 'user1' + 'username' => 'user1', ] ); @@ -134,7 +134,7 @@ public function test_slicemode() : void { 'M 0 0 L 0 2111 L 800 2111 L 800 0 Z M 72 47 L 481 47 L 481 349 L 72 349 Z', 'M 0 0 L 0 2111 L 800 2111 L 800 0 Z M 72 47 L 649 47 L 649 349 L 72 349 Z', // When all places are visible, there is no overlay anymore. - null + null, ]; $overlay = $mapworker->get_attribute('learningmap-overlay', 'd'); $this->assertEquals('M 0 0 L 0 2111 L 800 2111 L 800 0 Z M 37 12 L 137 12 L 137 112 L 37 112 Z', $overlay); @@ -172,9 +172,9 @@ public function test_visibility() : void { ['p0', 'p1', 'p0_1', 'p4', 'p1_4', 'p2', 'p2_3', 'p3', 'p2_6', 'p6', 'p3_6', 'p4_5', 'p5', 'p5_6'], ['p0', 'p1', 'p0_1', 'p4', 'p1_4', 'p2', 'p2_3', 'p3', 'p2_6', 'p6', 'p3_6', 'p4_5', 'p5', 'p5_6', 'p6_8', 'p8'], ['p0', 'p1', 'p0_1', 'p4', 'p1_4', 'p2', 'p2_3', 'p3', 'p2_6', 'p6', 'p3_6', 'p4_5', 'p5', 'p5_6', 'p6_8', 'p8', 'p8_9', - 'p9'], + 'p9', ], ['p0', 'p1', 'p0_1', 'p4', 'p1_4', 'p2', 'p2_3', 'p3', 'p2_6', 'p6', 'p3_6', 'p4_5', 'p5', 'p5_6', 'p6_8', 'p8', 'p8_9', - 'p9'], + 'p9', ], ]; for ($i = 0; $i < count($placestore['places']); $i++) {