From 7e37dbd449a85eeb2a8a7c4946e441cc2fae1bd5 Mon Sep 17 00:00:00 2001 From: LuisParada7 Date: Tue, 30 Apr 2024 10:17:07 -0500 Subject: [PATCH 1/2] Fix_line_endings_and_whitespace --- .../course_action_section_duplicate.php | 4 +- classes/webservice/ws_feed.php | 2 +- layout/course-index-category.php | 64 +++++++++---------- layout/default.php | 24 +++---- .../behat_theme_snap_behat_permissions.php | 2 +- tests/course_module_recycle_bin_test.php | 2 +- tests/custom_menu_spacing_test.php | 2 +- tests/local_test.php | 2 +- tests/recent_forum_activity_test.php | 2 +- tests/urls_and_strings_check_test.php | 4 +- .../src/app/app.component.html | 1 - 11 files changed, 54 insertions(+), 55 deletions(-) diff --git a/classes/renderables/course_action_section_duplicate.php b/classes/renderables/course_action_section_duplicate.php index a7beca9ea..3619963ca 100644 --- a/classes/renderables/course_action_section_duplicate.php +++ b/classes/renderables/course_action_section_duplicate.php @@ -36,7 +36,7 @@ class course_action_section_duplicate extends course_action_section_base { * course_action_section_duplicate constructor. * @param \stdClass $course * @param section_info $section - * @param bool $onsectionpage + * @param bool $onsectionpage */ public function __construct($course, section_info $section, $onsectionpage = false) { if ($onsectionpage) { @@ -55,4 +55,4 @@ public function __construct($course, section_info $section, $onsectionpage = fal $this->url = $duplicatesectionurl; } } -} \ No newline at end of file +} diff --git a/classes/webservice/ws_feed.php b/classes/webservice/ws_feed.php index 059dfc7c3..7f0fc89c2 100644 --- a/classes/webservice/ws_feed.php +++ b/classes/webservice/ws_feed.php @@ -73,7 +73,7 @@ public static function service_returns() { 'extraClasses' => new external_value(PARAM_RAW, 'Feed item extra CSS classes'), 'fromCache' => new external_value(PARAM_INT, 'Data from cache flag'), 'itemId' => new external_value(PARAM_INT, 'Id item we are sending', VALUE_DEFAULT), - 'urlParameter' => new external_value(PARAM_BOOL,'Flag to add URL parameter', VALUE_OPTIONAL), + 'urlParameter' => new external_value(PARAM_BOOL, 'Flag to add URL parameter', VALUE_OPTIONAL), ]) ); } diff --git a/layout/course-index-category.php b/layout/course-index-category.php index 05ebf5d81..c531ddf42 100644 --- a/layout/course-index-category.php +++ b/layout/course-index-category.php @@ -49,48 +49,48 @@ categories; if (empty($categories)) { - $catname = get_string('courses', 'theme_snap'); - $catname = format_text($catname); - echo '

' . html_to_text(s($catname)) . '

'; + $catname = get_string('courses', 'theme_snap'); + $catname = format_text($catname); + echo '

' . html_to_text(s($catname)) . '

'; } else { - // Get the current category name and description. - $cat = reset($categories); - $catid = $cat->id; - $catname = format_text($cat->name); - $catdescription = $cat->description; + // Get the current category name and description. + $cat = reset($categories); + $catid = $cat->id; + $catname = format_text($cat->name); + $catdescription = $cat->description; - // Category edit link. - $editcatagory = ''; - if (can_edit_in_category($catid)) { - $editurl = new moodle_url('/course/editcategory.php', ['id' => $catid]); - $editcatagory = '
' - .get_string('categoryedit', 'theme_snap').'
'; + // Category edit link. + $editcatagory = ''; + if (can_edit_in_category($catid)) { + $editurl = new moodle_url('/course/editcategory.php', ['id' => $catid]); + $editcatagory = '
' + .get_string('categoryedit', 'theme_snap').'
'; } - // Category summary. - $catsummary = ''; - if ($catdescription) { - $content = context_coursecat::instance($cat->id); - $catdescription = file_rewrite_pluginfile_urls($catdescription, - 'pluginfile.php', $content->id, 'coursecat', 'description', null); - $options = array('noclean' => true, 'overflowdiv' => false); - $catsummary = '
' - .format_text($catdescription, $cat->descriptionformat, $options). - $editcatagory.'
'; - } else { - // No summary, output edit link. - $catsummary = $editcatagory; + // Category summary. + $catsummary = ''; + if ($catdescription) { + $content = context_coursecat::instance($cat->id); + $catdescription = file_rewrite_pluginfile_urls($catdescription, + 'pluginfile.php', $content->id, 'coursecat', 'description', null); + $options = array('noclean' => true, 'overflowdiv' => false); + $catsummary = '
' + .format_text($catdescription, $cat->descriptionformat, $options). + $editcatagory.'
'; + } else { + // No summary, output edit link. + $catsummary = $editcatagory; } - echo '

' . html_to_text(s($catname)) . '

'; - echo $catsummary; + echo '

' . html_to_text(s($catname)) . '

'; + echo $catsummary; } $iscoursecat = $PAGE->context->contextlevel === CONTEXT_COURSECAT; $manageurl = false; if (has_capability('moodle/category:manage', $PAGE->context)) { - $manageurl = new moodle_url('/course/management.php'); - if ($iscoursecat) { - echo '
' . $OUTPUT->cover_image_selector() . '
'; + $manageurl = new moodle_url('/course/management.php'); + if ($iscoursecat) { + echo '
' . $OUTPUT->cover_image_selector() . '
'; } } ?> diff --git a/layout/default.php b/layout/default.php index c3710f09e..1c8561e5d 100644 --- a/layout/default.php +++ b/layout/default.php @@ -67,28 +67,28 @@
- page_heading(); - echo $OUTPUT->course_header(); - // Content bank for Snap. - if ($PAGE->pagetype === 'contentbank') { - echo $OUTPUT->snap_content_bank(); + page_heading(); + echo $OUTPUT->course_header(); + // Content bank for Snap. + if ($PAGE->pagetype === 'contentbank') { + echo $OUTPUT->snap_content_bank(); } ?>
page->user_is_editing() && $PAGE->pagetype == 'site-index') { - echo $OUTPUT->cover_image_selector(); + if ($this->page->user_is_editing() && $PAGE->pagetype == 'site-index') { + echo $OUTPUT->cover_image_selector(); } } // End else. if ($PAGE->pagetype == 'admin-search') { - echo implode('', $PAGE->get_header_actions()); + echo implode('', $PAGE->get_header_actions()); } ?> diff --git a/tests/behat/behat_theme_snap_behat_permissions.php b/tests/behat/behat_theme_snap_behat_permissions.php index 54a410717..ce9768fec 100644 --- a/tests/behat/behat_theme_snap_behat_permissions.php +++ b/tests/behat/behat_theme_snap_behat_permissions.php @@ -87,7 +87,7 @@ public function i_set_the_following_system_permissions_of_role($rolename, $table * Sets a specific capability for a student inside a course. * @param string $capability */ - public function i_set_activityvisibility_capability_to_student ($capability) { + public function i_set_activityvisibility_capability_to_student($capability) { global $DB; $DB->insert_record('role_capabilities', array( diff --git a/tests/course_module_recycle_bin_test.php b/tests/course_module_recycle_bin_test.php index 1000a015a..e4b134fd7 100644 --- a/tests/course_module_recycle_bin_test.php +++ b/tests/course_module_recycle_bin_test.php @@ -51,7 +51,7 @@ class course_module_recycle_bin_test extends \advanced_testcase { /** * Setup for each test. */ - protected function setUp():void { + protected function setUp(): void { global $CFG; $CFG->theme = 'snap'; diff --git a/tests/custom_menu_spacing_test.php b/tests/custom_menu_spacing_test.php index cb9f2042d..295a0ba0e 100644 --- a/tests/custom_menu_spacing_test.php +++ b/tests/custom_menu_spacing_test.php @@ -35,7 +35,7 @@ class custom_menu_spacing_test extends \advanced_testcase { /** * Setup for each test. */ - protected function setUp():void { + protected function setUp(): void { global $CFG; $CFG->theme = 'snap'; $this->resetAfterTest(true); diff --git a/tests/local_test.php b/tests/local_test.php index 11531c220..303987b23 100644 --- a/tests/local_test.php +++ b/tests/local_test.php @@ -1434,7 +1434,7 @@ public function test_course_completion_progress_limit() { * @throws \dml_exception */ - public function completion_activity_helper ($student, $teacher, $courses) { + public function completion_activity_helper($student, $teacher, $courses) { global $DB; $generator = $this->getDataGenerator(); $courseids = []; diff --git a/tests/recent_forum_activity_test.php b/tests/recent_forum_activity_test.php index 997c1439a..04521881b 100644 --- a/tests/recent_forum_activity_test.php +++ b/tests/recent_forum_activity_test.php @@ -84,7 +84,7 @@ protected function plugin_present($component) { * Pre-requisites for tests. * @throws \coding_exception */ - public function setUp():void { + public function setUp(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/forum/lib.php'); diff --git a/tests/urls_and_strings_check_test.php b/tests/urls_and_strings_check_test.php index fba1bdbe4..7193090ac 100644 --- a/tests/urls_and_strings_check_test.php +++ b/tests/urls_and_strings_check_test.php @@ -29,7 +29,7 @@ class urls_and_strings_check_test extends \advanced_testcase { /** * Setup for each test. */ - protected function setUp():void { + protected function setUp(): void { $this->resetAfterTest(); } @@ -102,7 +102,7 @@ public function gettranslations() { ]; } - public function test_edit_button () { + public function test_edit_button() { global $PAGE; $renderer = $PAGE->get_renderer('theme_snap', 'core', RENDERER_TARGET_GENERAL); diff --git a/vendorjs/snap-custom-elements/src/app/app.component.html b/vendorjs/snap-custom-elements/src/app/app.component.html index 5226d57f5..a0c0f017f 100644 --- a/vendorjs/snap-custom-elements/src/app/app.component.html +++ b/vendorjs/snap-custom-elements/src/app/app.component.html @@ -17,4 +17,3 @@

CLI Document

Angular blog

- From 490d1ff2c276106c79f15fed134237821481bf9b Mon Sep 17 00:00:00 2001 From: LuisParada7 Date: Fri, 26 Apr 2024 01:06:19 -0500 Subject: [PATCH 2/2] Fix short syntax array --- classes/activity.php | 30 ++-- classes/admin_setting_configcolorcategory.php | 2 +- .../activity_retrieval_strategy.php | 14 +- classes/controller/addsection_controller.php | 10 +- classes/controller/controller_abstract.php | 2 +- classes/controller/kernel.php | 2 +- .../controller/mediaresource_controller.php | 14 +- classes/controller/pagemod_controller.php | 12 +- classes/controller/router.php | 2 +- .../snap_personal_menu_controller.php | 20 +-- classes/course_total_grade.php | 14 +- classes/image.php | 4 +- classes/local.php | 62 +++---- classes/message.php | 4 +- classes/mod_hvp_renderer.php | 4 +- classes/output/core/course_renderer.php | 18 +- classes/output/format_section_trait.php | 78 ++++----- classes/output/mod_folder_renderer.php | 8 +- classes/output/shared.php | 136 ++++++++-------- .../course_action_section_delete.php | 4 +- classes/services/course.php | 12 +- classes/webservice/ws_course_card.php | 4 +- .../webservice/ws_course_cards_categories.php | 4 +- classes/webservice/ws_course_cards_data.php | 8 +- .../webservice/ws_file_manager_options.php | 6 +- config.php | 154 +++++++++--------- db/caches.php | 4 +- db/upgrade.php | 4 +- index.php | 2 +- layout/faux_site_index.php | 24 +-- layout/nav.php | 4 +- lib.php | 30 ++-- rest.php | 2 +- settings/course_settings.php | 4 +- settings/cover_settings.php | 8 +- settings/feature_spots_settings.php | 6 +- settings/login_settings.php | 8 +- settings/personal_menu_settings.php | 4 +- settings/snap_basics.php | 4 +- tests/activity_test.php | 34 ++-- tests/assign_test.php | 30 ++-- tests/behat/behat_theme_snap.php | 14 +- tests/behat/behat_theme_snap_behat_course.php | 4 +- ...hat_theme_snap_behat_course_categories.php | 18 +- .../behat/behat_theme_snap_behat_general.php | 4 +- .../behat_theme_snap_behat_permissions.php | 6 +- .../behat_theme_snap_category_colors.php | 12 +- tests/controller/kernel_test.php | 12 +- tests/controller/router_test.php | 6 +- tests/core_renderer_test.php | 8 +- tests/course_module_recycle_bin_test.php | 6 +- tests/course_total_grade_test.php | 12 +- tests/dashboard_appendices_test.php | 4 +- tests/gradebookaccess_test.php | 12 +- tests/local_test.php | 54 +++--- tests/recent_forum_activity_test.php | 8 +- tests/render_edit_mode_test.php | 4 +- tests/services_course_test.php | 30 ++-- ...service_ws_course_card_categories_test.php | 2 +- tests/webservice_ws_course_card_data_test.php | 2 +- tests/webservice_ws_course_card_test.php | 2 +- tests/webservice_ws_feed_activity_test.php | 14 +- 62 files changed, 515 insertions(+), 515 deletions(-) diff --git a/classes/activity.php b/classes/activity.php index 3746ab457..c0b012023 100644 --- a/classes/activity.php +++ b/classes/activity.php @@ -225,7 +225,7 @@ public static function assign_meta(\cm_info $modinst) { AND ac.subtype='assignsubmission' AND plugin!='comments' GROUP BY a.id;"; - $submissionsenabled = $DB->get_records_sql($sql, array($courseid)); + $submissionsenabled = $DB->get_records_sql($sql, [$courseid]); $coursequeried = $courseid; } @@ -323,7 +323,7 @@ public static function forum_meta(\cm_info $modinst) { public static function assign_ungraded($courseids, $since = null) { global $DB; - $ungraded = array(); + $ungraded = []; if ($since === null) { $since = time() - (12 * WEEKSECS); @@ -415,7 +415,7 @@ public static function quiz_ungraded($courseids, $since = null) { $since = time() - (12 * WEEKSECS); } - $ungraded = array(); + $ungraded = []; foreach ($courseids as $courseid) { @@ -489,13 +489,13 @@ public static function assign_num_submissions_ungraded($courseid, $modid) { } // Check to see if this assign is graded. - $params = array( + $params = [ 'courseid' => $courseid, 'itemtype' => 'mod', 'itemmodule' => 'assign', 'gradetypenone' => GRADE_TYPE_NONE, 'gradetypetext' => GRADE_TYPE_TEXT, - ); + ]; $sql = 'SELECT DISTINCT iteminstance FROM {grade_items} @@ -590,7 +590,7 @@ protected static function std_num_submissions($courseid, $extraselect = '') { global $DB; - static $modtotalsbyid = array(); + static $modtotalsbyid = []; if (!isset($modtotalsbyid[$maintable][$courseid])) { // Results are not cached, so lets get them. @@ -640,7 +640,7 @@ protected static function std_num_submissions($courseid, public static function assign_num_submissions($courseid, $modid) { global $DB; - static $modtotalsbyid = array(); + static $modtotalsbyid = []; if (!isset($modtotalsbyid['assign'][$courseid])) { // Results are not cached, so lets get them. @@ -799,7 +799,7 @@ public static function get_submission_row($courseid, $mod, $submissiontable, $mo global $DB, $USER; // Note: Caches all submissions to minimise database transactions. - static $submissions = array(); + static $submissions = []; // Pull from cache? if (!PHPUNIT_TEST) { @@ -1056,7 +1056,7 @@ public static function instance_activity_dates($courseid, \cm_info $mod, $timeop $assigninstance = $assign->id; $dates = $moddates[$courseid . '_' . $modname][$assigninstance]; // Check if there is any extension. - $flags = $DB->get_record('assign_user_flags', array('assignment' => $assigninstance, 'userid' => $USER->id)); + $flags = $DB->get_record('assign_user_flags', ['assignment' => $assigninstance, 'userid' => $USER->id]); if (!empty($flags->extensionduedate)) { // If there is an extension, then assign the duedate of the extension. $timeclose = $flags->extensionduedate; @@ -1133,7 +1133,7 @@ public static function instance_activity_dates($courseid, \cm_info $mod, $timeop public static function grade_row($courseid, $mod) { global $DB, $USER; - static $grades = array(); + static $grades = []; if (isset($grades[$courseid.'_'.$mod->modname]) && isset($grades[$courseid.'_'.$mod->modname][$mod->instance]) @@ -1163,12 +1163,12 @@ public static function grade_row($courseid, $mod) { OR gg.feedback IS NOT NULL ) "; - $params = array( + $params = [ 'modname' => $mod->modname, 'courseid1' => $courseid, 'courseid2' => $courseid, 'userid' => $USER->id, - ); + ]; $grades[$courseid.'_'.$mod->modname] = $DB->get_records_sql($sql, $params); if (isset($grades[$courseid.'_'.$mod->modname][$mod->instance])) { @@ -1218,7 +1218,7 @@ public static function events_graded($onlyactive = true, $showfrom = null) { $params = array_merge($params, [$USER->id, $showfrom, $showfrom]); $grades = $DB->get_records_sql($sql, $params, 0, 5); - $eventdata = array(); + $eventdata = []; foreach ($grades as $grade) { $eventdata[] = $grade; } @@ -1680,7 +1680,7 @@ private static function get_groups_sql($courseid) { $sqlgroupsjoin = ''; $sqlgroupswhere = ''; - $groupparams = array(); + $groupparams = []; $course = get_course($courseid); $groupmode = groups_get_course_groupmode($course); @@ -1703,7 +1703,7 @@ private static function get_groups_sql($courseid) { WHERE g.courseid = :courseid2 AND gm.userid = :userid)"; } - return array($sqlgroupsjoin, $sqlgroupswhere, $groupparams); + return [$sqlgroupsjoin, $sqlgroupswhere, $groupparams]; } /** diff --git a/classes/admin_setting_configcolorcategory.php b/classes/admin_setting_configcolorcategory.php index ec625c611..10b1f6bed 100644 --- a/classes/admin_setting_configcolorcategory.php +++ b/classes/admin_setting_configcolorcategory.php @@ -128,7 +128,7 @@ public function write_setting($data) { */ private function validate_text($data) { $temp = $data; - $symbols = array('{', '}', '"'); + $symbols = ['{', '}', '"']; foreach ($symbols as $symbol) { $temp = str_replace($symbol, '', $temp); } diff --git a/classes/calendar/event/strategies/activity_retrieval_strategy.php b/classes/calendar/event/strategies/activity_retrieval_strategy.php index afc8cd832..4c2e02b4a 100644 --- a/classes/calendar/event/strategies/activity_retrieval_strategy.php +++ b/classes/calendar/event/strategies/activity_retrieval_strategy.php @@ -62,23 +62,23 @@ protected function get_raw_events_legacy_implementation( ) { global $DB, $CFG; - $params = array(); + $params = []; // Quick test. if (empty($users) && empty($groups) && empty($courses) && empty($categories)) { - return array(); + return []; } if (is_numeric($users)) { - $users = array($users); + $users = [$users]; } if (is_numeric($groups)) { - $groups = array($groups); + $groups = [$groups]; } if (is_numeric($courses)) { - $courses = array($courses); + $courses = [$courses]; } if (is_numeric($categories)) { - $categories = array($categories); + $categories = [$categories]; } // Array of filter conditions. To be concatenated by the OR operator. @@ -133,7 +133,7 @@ protected function get_raw_events_legacy_implementation( // events no matter what. Allowing the code to proceed might return a completely // valid query with only time constraints, thus selecting ALL events in that time frame! if (empty($filters)) { - return array(); + return []; } // Build our clause for the filters. diff --git a/classes/controller/addsection_controller.php b/classes/controller/addsection_controller.php index 92c9913ea..cdd9e238b 100644 --- a/classes/controller/addsection_controller.php +++ b/classes/controller/addsection_controller.php @@ -66,19 +66,19 @@ public function addsection_action() { $numsections = course_get_format($courseid)->get_last_section_number() + 1; course_create_sections_if_missing($course, range(0, $numsections)); - $options = array( + $options = [ 'subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => -1, 'context' => $context, - ); + ]; $modinfo = get_fast_modinfo($course); $section = $modinfo->get_section_info($numsections, MUST_EXIST); $summarytext = file_save_draft_area_files($draftitemid, $context->id, 'course', 'section', $section->id, $options, $summarytext); - $DB->set_field('course_sections', 'name', $sectioname, array('id' => $section->id)); - $DB->set_field('course_sections', 'summary', $summarytext, array('id' => $section->id)); - $DB->set_field('course_sections', 'summaryformat', $summaryformat, array('id' => $section->id)); + $DB->set_field('course_sections', 'name', $sectioname, ['id' => $section->id]); + $DB->set_field('course_sections', 'summary', $summarytext, ['id' => $section->id]); + $DB->set_field('course_sections', 'summaryformat', $summaryformat, ['id' => $section->id]); rebuild_course_cache($course->id); redirect(course_get_url($course, $section->section)); diff --git a/classes/controller/controller_abstract.php b/classes/controller/controller_abstract.php index 0a943dc8f..2ef6e4d34 100644 --- a/classes/controller/controller_abstract.php +++ b/classes/controller/controller_abstract.php @@ -32,7 +32,7 @@ abstract class controller_abstract { * @param array $params * @return \moodle_url */ - public function new_url($params = array()) { + public function new_url($params = []) { global $PAGE; $url = $PAGE->url; diff --git a/classes/controller/kernel.php b/classes/controller/kernel.php index d9a844fdb..d3f555b2f 100644 --- a/classes/controller/kernel.php +++ b/classes/controller/kernel.php @@ -68,7 +68,7 @@ public function resolve_controller_callback($action) { $controller->init($action); - return array($controller, $method); + return [$controller, $method]; } /** diff --git a/classes/controller/mediaresource_controller.php b/classes/controller/mediaresource_controller.php index 92e7613cf..d07ae04c2 100644 --- a/classes/controller/mediaresource_controller.php +++ b/classes/controller/mediaresource_controller.php @@ -66,10 +66,10 @@ private function get_media_html($resource, $context, \cm_info $cm) { } else { $file = reset($files); unset($files); - $embedoptions = array( + $embedoptions = [ \core_media_manager::OPTION_TRUSTED => true, \core_media_manager::OPTION_BLOCK => true, - ); + ]; $path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$file->get_filepath().$file->get_filename(); $moodleurl = new \moodle_url('/pluginfile.php' . $path); $embedhtml = \core_media_manager::instance()->embed_url($moodleurl, $resource->name, 0, 0, $embedoptions); @@ -102,11 +102,11 @@ private function read_media() { $context = \context_module::instance($cm->id); // Trigger module instance viewed event. - $event = \mod_resource\event\course_module_viewed::create(array( + $event = \mod_resource\event\course_module_viewed::create([ 'objectid' => $cm->instance, 'context' => $context, - )); - $resource = $DB->get_record('resource', array('id' => $cm->instance)); + ]); + $resource = $DB->get_record('resource', ['id' => $cm->instance]); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $COURSE); $event->add_record_snapshot('resource', $resource); @@ -131,10 +131,10 @@ private function read_media() { public function get_media_action() { $media = $this->read_media(); - return json_encode(array( + return json_encode([ 'html' => $media->content, 'completionhtml' => $media->completionhtml, - )); + ]); } } diff --git a/classes/controller/pagemod_controller.php b/classes/controller/pagemod_controller.php index 6ffa6f8a8..2f0acade6 100644 --- a/classes/controller/pagemod_controller.php +++ b/classes/controller/pagemod_controller.php @@ -64,10 +64,10 @@ private function read_page() { $context = $PAGE->context; // Trigger module instance viewed event. - $event = \mod_page\event\course_module_viewed::create(array( + $event = \mod_page\event\course_module_viewed::create([ 'objectid' => $page->id, 'context' => $context, - )); + ]); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $COURSE); $event->add_record_snapshot('page', $page); @@ -90,11 +90,11 @@ private function read_page() { public function get_page_action() { $page = $this->read_page(); - return json_encode(array( + return json_encode([ 'html' => $page->content, 'cmid' => $page->cmid, 'completionhtml' => $page->completionhtml, - )); + ]); } /** @@ -105,11 +105,11 @@ public function get_page_action() { public function read_page_action() { $page = $this->read_page(); - return json_encode(array( + return json_encode([ 'id' => $page->id, 'cmid' => $page->cmid, 'completionhtml' => $page->completionhtml, - )); + ]); } } diff --git a/classes/controller/router.php b/classes/controller/router.php index c76845ed6..181730c43 100644 --- a/classes/controller/router.php +++ b/classes/controller/router.php @@ -78,7 +78,7 @@ public function route_action($action) { } else if ($reflection->getMethod($method)->isPublic() !== true) { throw new coding_exception("The controller callback is not public: $method"); } - return array($controller, $method); + return [$controller, $method]; } throw new coding_exception("Unable to handle request for $method"); } diff --git a/classes/controller/snap_personal_menu_controller.php b/classes/controller/snap_personal_menu_controller.php index 565c8b6c5..24ee0ca50 100644 --- a/classes/controller/snap_personal_menu_controller.php +++ b/classes/controller/snap_personal_menu_controller.php @@ -52,9 +52,9 @@ public function get_deadlines_action() { * @return string */ public function get_forumposts_action() { - return json_encode(array( + return json_encode([ 'html' => \theme_snap\local::render_recent_forum_activity(), - )); + ]); } /** @@ -63,9 +63,9 @@ public function get_forumposts_action() { * @return string */ public function get_graded_action() { - return json_encode(array( + return json_encode([ 'html' => \theme_snap\local::graded(), - )); + ]); } /** @@ -74,9 +74,9 @@ public function get_graded_action() { * @return string */ public function get_messages_action() { - return json_encode(array( + return json_encode([ 'html' => \theme_snap\local::messages(), - )); + ]); } /** @@ -85,9 +85,9 @@ public function get_messages_action() { * @return string */ public function get_grading_action() { - return json_encode(array( + return json_encode([ 'html' => \theme_snap\local::grading(), - )); + ]); } /** @@ -101,9 +101,9 @@ public function get_courseinfo_action() { $courseids = explode(',', $courseids); } $courseinfo = \theme_snap\local::courseinfo($courseids); - return json_encode(array( + return json_encode([ 'info' => $courseinfo, - )); + ]); } /** diff --git a/classes/course_total_grade.php b/classes/course_total_grade.php index d5521a0ba..1a845bf6d 100644 --- a/classes/course_total_grade.php +++ b/classes/course_total_grade.php @@ -72,10 +72,10 @@ public function __construct($user, $gpr, $course) { $this->context = \context_course::instance($course->id); $this->gradebookroles = $CFG->gradebookroles; - $this->showtotalsifcontainhidden = array(); + $this->showtotalsifcontainhidden = []; - $this->studentcourseids = array(); - $this->teachercourses = array(); + $this->studentcourseids = []; + $this->teachercourses = []; $roleids = explode(',', get_config('moodle', 'gradebookroles')); $this->showtotalsifcontainhidden[$course->id] = grade_get_setting($course->id, @@ -106,7 +106,7 @@ public function get_course_total($studentcoursesonly = true) { global $USER; // Default 'empty' output. - $output = array("value" => '-', "percentage" => '-'); + $output = ["value" => '-', "percentage" => '-']; if ($studentcoursesonly && !$this->isstudent) { return $output; @@ -128,13 +128,13 @@ public function get_course_total($studentcoursesonly = true) { $courseitem = grade_item::fetch_course_item($this->course->id); // Get the stored grade. - $coursegrade = new grade_grade(array('itemid' => $courseitem->id, 'userid' => $this->user->id)); + $coursegrade = new grade_grade(['itemid' => $courseitem->id, 'userid' => $this->user->id]); $coursegrade->grade_item =& $courseitem; $finalgrade = $coursegrade->finalgrade; // Return error when grade needs updating. if ($coursegrade->grade_item->needsupdate) { - return array("value" => get_string('error'), "percentage" => '-'); + return ["value" => get_string('error'), "percentage" => '-']; } $canviewhidden = has_capability('moodle/grade:viewhidden', $this->context); @@ -172,6 +172,6 @@ public function get_course_total($studentcoursesonly = true) { true, GRADE_DISPLAY_TYPE_PERCENTAGE); $value = grade_format_gradevalue(unformat_float($finalgrade), $coursegrade->grade_item); - return array("value" => $value, "percentage" => $percentage); + return ["value" => $value, "percentage" => $percentage]; } } diff --git a/classes/image.php b/classes/image.php index ffea6b9af..74e151bce 100644 --- a/classes/image.php +++ b/classes/image.php @@ -178,13 +178,13 @@ public static function resize ( \imagecopybicubic($newimage, $im, 0, 0, 0, 0, $newwidth, $newheight, $imageinfo->width, $imageinfo->height); $fs = \get_file_storage(); - $newimageparams = array( + $newimageparams = [ 'contextid' => $contextid, 'component' => $component, 'filearea' => $filearea, 'itemid' => $itemid, 'filepath' => '/', - ); + ]; \ob_start(); if ($imagefnc == 'imagejpeg') { diff --git a/classes/local.php b/classes/local.php index 9c9024fec..5d4001308 100644 --- a/classes/local.php +++ b/classes/local.php @@ -56,11 +56,11 @@ class local { * @return bool */ public static function item_has_grade_or_feedback($item) { - $typekeys = array ('grade', 'feedback'); + $typekeys = ['grade', 'feedback']; foreach ($typekeys as $typekey) { if (!empty($item[$typekey]['content'])) { // Set grade content to null string if it contents - or a blank space. - $item[$typekey]['content'] = str_ireplace(array('-', ' '), '', $item[$typekey]['content']); + $item[$typekey]['content'] = str_ireplace(['-', ' '], '', $item[$typekey]['content']); } // Is there an error message in the content (can't check on message as it is localized, // so check on the class for gradingerror. @@ -118,10 +118,10 @@ public static function course_grade($course, $oncoursedashboard = false) { // Get course grade_item. $courseitem = \grade_item::fetch_course_item($course->id); // Get the stored grade. - $coursegrade = new \grade_grade(array('itemid' => $courseitem->id, 'userid' => $USER->id)); + $coursegrade = new \grade_grade(['itemid' => $courseitem->id, 'userid' => $USER->id]); $coursegrade->grade_item =& $courseitem; - $feedbackurl = new \moodle_url('/grade/report/user/index.php', array('id' => $course->id)); + $feedbackurl = new \moodle_url('/grade/report/user/index.php', ['id' => $course->id]); // Default feedbackobj. $feedbackobj = (object) [ 'feedbackurl' => $feedbackurl->out(), @@ -130,11 +130,11 @@ public static function course_grade($course, $oncoursedashboard = false) { if (!$coursegrade->is_hidden() || $canviewhidden) { // Use overview grade report to get course total - this is to take hidden grade settings into account. - $gpr = new \grade_plugin_return(array( + $gpr = new \grade_plugin_return([ 'type' => 'report', 'plugin' => 'overview', 'courseid' => $course->id, - 'userid' => $USER->id, ) + 'userid' => $USER->id, ] ); // Create a report instance. @@ -169,7 +169,7 @@ public static function get_course_categories($course) { } $categories = []; - $category = $DB->get_record('course_categories', array('id' => $course->category)); + $category = $DB->get_record('course_categories', ['id' => $course->category]); if (!$category) { throw new \moodle_exception('unknowncategory'); } @@ -204,7 +204,7 @@ public static function resolve_theme() { global $CFG, $USER, $SESSION, $COURSE; if (empty($CFG->themeorder)) { - $themeorder = array('course', 'category', 'session', 'user', 'site'); + $themeorder = ['course', 'category', 'session', 'user', 'site']; } else { $themeorder = $CFG->themeorder; // Just in case, make sure we always use the site theme if nothing else matched. @@ -456,7 +456,7 @@ public static function conditionally_unavailable_elements($course) { public static function courseinfo($courseids) { global $CFG; - $courseinfo = array(); + $courseinfo = []; $courses = enrol_get_my_courses(['enablecompletion', 'showgrades']); @@ -482,10 +482,10 @@ public static function courseinfo($courseids) { } $course = $courses[$courseid]; - $courseinfo[$courseid] = (object) array( + $courseinfo[$courseid] = (object) [ 'course' => $courseid, 'completion' => self::course_completion_progress($course), - ); + ]; if (!empty($showgrades)) { $feedback = self::course_grade($course); @@ -508,7 +508,7 @@ public static function courseinfo($courseids) { * @return int */ public static function course_participant_count($courseid, $modname = null) { - static $participantcount = array(); + static $participantcount = []; if (defined('PHPUNIT_TEST') && PHPUNIT_TEST) { $participantcount = []; @@ -594,7 +594,7 @@ public static function count_enrolled_users(\context $context, $withcapability = $sqlgroupsjoin = ''; $sqlgroupswhere = ''; - $params = array(); + $params = []; $course = get_course($context->instanceid); $groupmode = groups_get_course_groupmode($course); @@ -681,16 +681,16 @@ public static function get_user_messages($userid, $since = null, $limitfrom = 0, $lastmessage ORDER BY m.timecreated DESC"; - $params = array( + $params = [ 'userid' => $userid, 'fromdate' => $since, 'actiondeleted' => \core_message\api::MESSAGE_ACTION_DELETED, 'actionread' => \core_message\api::MESSAGE_ACTION_READ, - ); + ]; $records = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); - $messages = array(); + $messages = []; foreach ($records as $record) { $message = new message($record); $message->set_fromuser(\user_picture::unalias($record, null, 'useridfrom', 'fromuser')); @@ -742,9 +742,9 @@ public static function messages_data($renderhtml = false, $limitfrom = 0, $limit foreach ($messages as $message) { // This URL will be to redirect the user to an unread message through the personal menu feed and open // the specific message in the message index page. - $url = new \moodle_url('/message/index.php', array( + $url = new \moodle_url('/message/index.php', [ 'viewing' => 'unread', - 'user2' => $message->useridfrom, ) + 'user2' => $message->useridfrom, ] ); if (!$renderhtml) { @@ -814,9 +814,9 @@ public static function relative_time($timeinpast, $relativeto = null) { $relativetext = get_string('ago', 'message', $relativetext); } $datetime = date(\DateTime::W3C, $timeinpast); - return html_writer::tag('time', $relativetext, array( + return html_writer::tag('time', $relativetext, [ 'is' => 'relative-time', - 'datetime' => $datetime, ) + 'datetime' => $datetime, ] ); } @@ -891,7 +891,7 @@ public static function graded_data($onlyactive = true, $renderhtml = false) { $releasedon = isset($grade->timemodified) ? $grade->timemodified : $grade->timecreated; $meta = get_string('released', 'theme_snap', $output->friendly_datetime($releasedon)); - $grade = new \grade_grade(array('itemid' => $grade->itemid, 'userid' => $USER->id)); + $grade = new \grade_grade(['itemid' => $grade->itemid, 'userid' => $USER->id]); $snapfeedsurlparam = isset($CFG->theme_snap_feeds_url_parameter) ? $CFG->theme_snap_feeds_url_parameter : true; @@ -1071,7 +1071,7 @@ public static function all_ungraded($userid, $since = null) { $courseids = self::gradeable_courseids($userid); if (empty($courseids)) { - return array(); + return []; } if ($since === null) { @@ -1090,7 +1090,7 @@ public static function all_ungraded($userid, $since = null) { } } - usort($grading, array('self', 'sort_graded')); + usort($grading, ['self', 'sort_graded']); return $grading; } @@ -1178,7 +1178,7 @@ public static function extract_first_image($html) { if ($imagetags->item(0)) { $src = $imagetags->item(0)->getAttribute('src'); $alt = $imagetags->item(0)->getAttribute('alt'); - return array('src' => $src, 'alt' => $alt); + return ['src' => $src, 'alt' => $alt]; } else { return false; } @@ -1288,14 +1288,14 @@ public static function set_course_card_image($context, $originalfile) { if ($cardimage) { return $cardimage; } - $filespec = array( + $filespec = [ 'contextid' => $context->id, 'component' => 'theme_snap', 'filearea' => 'coursecard', 'itemid' => 0, 'filepath' => '/', 'filename' => 'course-card-'.$id.'-'.$filename, - ); + ]; $coursecardimage = $fs->create_file_from_storedfile($filespec, $originalfile); $coursecardimage = image::resize($coursecardimage, false, round($coursecardwidth)); return $coursecardimage; @@ -1557,14 +1557,14 @@ public static function process_coverimage(\context $context, $originalfile = fal $extension = pathinfo($filename, PATHINFO_EXTENSION); $newfilename .= '.'.$extension; - $filespec = array( + $filespec = [ 'contextid' => $context->id, 'component' => 'theme_snap', 'filearea' => 'coverimage', 'itemid' => 0, 'filepath' => '/', 'filename' => $newfilename, - ); + ]; $newfile = $fs->create_file_from_storedfile($filespec, $originalfile); $finfo = $newfile->get_imageinfo(); @@ -1594,7 +1594,7 @@ public static function get_page_mod($mod) { $sql = "SELECT * FROM {course_modules} cm JOIN {page} p ON p.id = cm.instance WHERE cm.id = ?"; - $page = $DB->get_record_sql($sql, array($mod->id)); + $page = $DB->get_record_sql($sql, [$mod->id]); $page->cmid = $mod->id; $context = \context_module::instance($mod->id); @@ -1900,11 +1900,11 @@ public static function recent_forum_activity($userorid = false, $limit = 10, $si ]; if ($post->type === 'hsuforum') { - $postuser = hsuforum_anonymize_user($postuser, (object)array( + $postuser = hsuforum_anonymize_user($postuser, (object)[ 'id' => $post->forum, 'course' => $post->course, 'anonymous' => $post->forumanonymous, - ), $post); + ], $post); } $activities[] = (object)[ diff --git a/classes/message.php b/classes/message.php index 4552c3881..7ee79d351 100644 --- a/classes/message.php +++ b/classes/message.php @@ -92,7 +92,7 @@ class message implements \renderable { */ protected $fromuser; - public function __construct($options = array()) { + public function __construct($options = array[]) { $this->set_options($options); } @@ -122,7 +122,7 @@ public function get_fromuser() { throw new \coding_exception('The message useridfrom is not set'); } $this->set_fromuser( - $DB->get_record('user', array('id' => $this->useridfrom), \core_user\fields::for_userpic() + $DB->get_record('user', ['id' => $this->useridfrom], \core_user\fields::for_userpic() ->get_sql('', false, '', '', false)->selects, MUST_EXIST) ); } diff --git a/classes/mod_hvp_renderer.php b/classes/mod_hvp_renderer.php index 98e75e2bf..88f03d52c 100644 --- a/classes/mod_hvp_renderer.php +++ b/classes/mod_hvp_renderer.php @@ -46,10 +46,10 @@ public function hvp_alter_styles(&$styles, $libraries=null, $embedtype=null) { $content = $this->get_settings('hvpcustomcss'); if (!empty($content)) { - $styles[] = (object) array( + $styles[] = (object) [ 'path' => $this->get_style_url($content), 'version' => '', - ); + ]; } } diff --git a/classes/output/core/course_renderer.php b/classes/output/core/course_renderer.php index f7b4a0de4..461f6a9e0 100644 --- a/classes/output/core/course_renderer.php +++ b/classes/output/core/course_renderer.php @@ -950,7 +950,7 @@ protected function mod_page_html(cm_info $mod) { $pmcontextattribute = 'data-pagemodcontext="'.$mod->context->id.'"'; $expandpagebutton = " -