diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 62b57f8..8c8f7f0 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -11,7 +11,7 @@ jobs: services: postgres: - image: postgres:10 # Moodle 3.4-3.5: 9.3-11.x / Moodle 3.6-3.8: 9.4-11.x / Moodle 3.9: >=9.5 / Moodle 3.10-3.11: >=9.6 + image: postgres:9.6 # Moodle 3.4-3.5: 9.3-11.x / Moodle 3.6-3.8: 9.4-11.x / Moodle 3.9: >=9.5 / Moodle 3.10-3.11: >=9.6 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' @@ -19,7 +19,7 @@ jobs: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 mariadb: - image: mariadb:10.5 # Moodle 3.4-3.8: >=5.5.31 / Moodle 3.9-3.11 >=10.2.29 / 10.6 breaks Moodle, see MDL-72131 + image: mariadb:10.2 # Moodle 3.4-3.8: >=5.5.31 / Moodle 3.9-3.11 >=10.2.29 / 10.6 breaks Moodle, see MDL-72131 env: MYSQL_USER: 'root' MYSQL_ALLOW_EMPTY_PASSWORD: "true" @@ -38,50 +38,46 @@ jobs: - php: '7.0' # 7.0-7.2 moodle-branch: 'MOODLE_34_STABLE' database: mariadb + plugin-ci: ^3 # Moodle 3.5 #- php: '7.0' # 7.0-7.2 # moodle-branch: 'MOODLE_35_STABLE' - # database: mariadb + # database: pgsql + # plugin-ci: ^3 # Moodle 3.6 #- php: '7.0' # 7.0-7.3 # moodle-branch: 'MOODLE_36_STABLE' # database: mariadb + # plugin-ci: ^3 # Moodle 3.7 #- php: '7.1' # 7.1-7.3 # moodle-branch: 'MOODLE_37_STABLE' - # database: mariadb + # database: pgsql + # plugin-ci: ^3 # Moodle 3.8 - #- php: '7.1' # 7.1-7.4 + #- php: '7.2' # 7.1-7.4 # moodle-branch: 'MOODLE_38_STABLE' # database: mariadb + # plugin-ci: ^3 # Moodle 3.9 - #- php: '7.2' # 7.2-7.4 - # moodle-branch: 'MOODLE_39_STABLE' - # database: mariadb - # Moodle 3.9, PostgreSQL - #- php: '7.2' # 7.2-7.4 + #- php: '7.3' # 7.2-7.4 # moodle-branch: 'MOODLE_39_STABLE' # database: pgsql + # plugin-ci: ^3 # Moodle 3.10 - #- php: '7.3' # 7.2-7.4 + #- php: '7.4' # 7.2-7.4 # moodle-branch: 'MOODLE_310_STABLE' # database: mariadb + # plugin-ci: ^4 # Moodle 3.11 - #- php: '7.4' # 7.3-8.0 - # moodle-branch: 'MOODLE_311_STABLE' - # database: mariadb - # Moodle 3.11, PostgreSQL - #- php: '7.4' # 7.3-8.0 - # moodle-branch: 'MOODLE_311_STABLE' - # database: pgsql - # Moodle 3.11, PHP 8.0 #- php: '8.0' # 7.3-8.0 # moodle-branch: 'MOODLE_311_STABLE' - # database: mariadb + # database: pgsql + # plugin-ci: ^4 steps: - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: plugin @@ -91,11 +87,13 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ matrix.extensions }} # PHP 8 changes ini-values: max_input_vars=5000 + # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". + # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). coverage: none - name: Initialise moodle-plugin-ci run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ${{ matrix.plugin-ci }} echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH sudo locale-gen en_AU.UTF-8 @@ -124,7 +122,7 @@ jobs: - name: Moodle Code Checker if: ${{ always() }} - run: moodle-plugin-ci codechecker --max-warnings 0 + run: moodle-plugin-ci phpcs --max-warnings 0 - name: Moodle PHPDoc Checker if: ${{ always() }} diff --git a/_course_changenumsections.php b/_course_changenumsections.php index 6092601..c2db693 100644 --- a/_course_changenumsections.php +++ b/_course_changenumsections.php @@ -51,10 +51,10 @@ } // END ADDED. -$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); $courseformatoptions = course_get_format($course)->get_format_options(); -$PAGE->set_url('/course/changenumsections.php', array('courseid' => $courseid)); +$PAGE->set_url('/course/changenumsections.php', ['courseid' => $courseid]); // TODO: Change? // Authorisation checks. @@ -106,8 +106,8 @@ // Don't go less than 0, intentionally redirect silently (for the case of // double clicks). if ($courseformatoptions['numsections'] >= 0) { - update_course((object)array('id' => $course->id, - 'numsections' => $courseformatoptions['numsections'])); + update_course((object)['id' => $course->id, + 'numsections' => $courseformatoptions['numsections'], ]); } // Overwriting returnurl to be consistent with block below even though we never get here. $returnurl = course_get_url($course); diff --git a/_course_editsection.php b/_course_editsection.php index 6c70514..e62a9c0 100644 --- a/_course_editsection.php +++ b/_course_editsection.php @@ -35,12 +35,12 @@ // REMOVED $sectionreturn . $deletesection = optional_param('delete', 0, PARAM_BOOL); -$PAGE->set_url('/course/format/multitopic/_course_editsection.php', array('id' => $id)); +$PAGE->set_url('/course/format/multitopic/_course_editsection.php', ['id' => $id]); // CHANGED LINE ABOVE: Custom script, and omit $sectionreturn. // NOTE: Can't revert this without changing reference to $PAGE->url ? -$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST); -$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST); +$section = $DB->get_record('course_sections', ['id' => $id], '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $section->course], '*', MUST_EXIST); // REMOVED sectionnum . require_login($course); @@ -84,7 +84,7 @@ $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->box_start('noticebox'); - $optionsyes = array('id' => $id, 'confirm' => 1, 'delete' => 1, 'sesskey' => sesskey()); + $optionsyes = ['id' => $id, 'confirm' => 1, 'delete' => 1, 'sesskey' => sesskey()]; $deleteurl = new \moodle_url('/course/format/multitopic/_course_editsection.php', $optionsyes); // CHANGED LINE ABOVE: Custom script. $formcontinue = new \single_button($deleteurl, get_string('delete')); @@ -100,13 +100,13 @@ } } -$editoroptions = array( +$editoroptions = [ 'context' => $context, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, - 'noclean' => true -); + 'noclean' => true, +]; // INCLUDED for Moodle >= 3.6. if ($CFG->version >= 2018120300) { $editoroptions['subdirs'] = true; @@ -116,11 +116,11 @@ $courseformat = course_get_format($course); $defaultsectionname = $courseformat->get_default_section_name($sectioninfo); // CHANGED: Use custom section info. -$customdata = array( +$customdata = [ 'cs' => $sectioninfo, 'editoroptions' => $editoroptions, - 'defaultsectionname' => $defaultsectionname -); + 'defaultsectionname' => $defaultsectionname, +]; $mform = $courseformat->editsection_form($PAGE->url, $customdata); // Set current value, make an editable copy of section_info object. diff --git a/_course_view.php b/_course_view.php index a5865b3..5adfdbb 100644 --- a/_course_view.php +++ b/_course_view.php @@ -82,27 +82,27 @@ } // END ADDED. - $params = array(); + $params = []; if (!empty($name)) { - $params = array('shortname' => $name); + $params = ['shortname' => $name]; } else if (!empty($idnumber)) { - $params = array('idnumber' => $idnumber); + $params = ['idnumber' => $idnumber]; } else if (!empty($id)) { - $params = array('id' => $id); + $params = ['id' => $id]; } else { throw new moodle_exception('unspecifycourseid', 'error'); } $course = $DB->get_record('course', $params, '*', MUST_EXIST); - $urlparams = array('id' => $course->id); + $urlparams = ['id' => $course->id]; // Sectionid should get priority over section number. // CHANGED. if ($sectionid) { - $section = $DB->get_record('course_sections', array('id' => $sectionid, 'course' => $course->id), '*', MUST_EXIST); + $section = $DB->get_record('course_sections', ['id' => $sectionid, 'course' => $course->id], '*', MUST_EXIST); } else { - $section = $DB->get_record('course_sections', array('section' => $section, 'course' => $course->id), '*', MUST_EXIST); + $section = $DB->get_record('course_sections', ['section' => $section, 'course' => $course->id], '*', MUST_EXIST); } if ($section->section) { // NOTE: This parameter is changed from number to ID, in renderer.php for view pages, and here for edit pages. @@ -230,7 +230,7 @@ } else if (!empty($return)) { redirect($CFG->wwwroot . $return); } else { - $url = new \moodle_url($PAGE->url, array('notifyeditingon' => 1)); + $url = new \moodle_url($PAGE->url, ['notifyeditingon' => 1]); redirect($url); } } else if (($edit == 0) && confirm_sesskey()) { @@ -251,7 +251,7 @@ // INCLUDED /course/format/onetopic/format.php $disableajax . if (!isset($USER->onetopic_da)) { - $USER->onetopic_da = array(); + $USER->onetopic_da = []; } if ($disableajax !== -1) { $USER->onetopic_da[$course->id] = $disableajax ? true : false; @@ -323,9 +323,9 @@ $sectionname = get_string('sectionname', "format_$course->format"); $sectiontitle = get_section_name($course, $section); $PAGE->set_title(get_string('coursesectiontitle', 'moodle', - array('course' => $course->fullname, 'sectiontitle' => $sectiontitle, 'sectionname' => $sectionname))); + ['course' => $course->fullname, 'sectiontitle' => $sectiontitle, 'sectionname' => $sectionname])); } else { - $PAGE->set_title(get_string('coursetitle', 'moodle', array('course' => $course->fullname))); + $PAGE->set_title(get_string('coursetitle', 'moodle', ['course' => $course->fullname])); } $PAGE->set_heading($course->fullname); @@ -349,16 +349,16 @@ // go to another page, (c) clicks Back button - the page will // automatically reload. Otherwise it would start with the wrong tick // values. - echo \html_writer::start_tag('form', array('action' => '.', 'method' => 'get')); + echo \html_writer::start_tag('form', ['action' => '.', 'method' => 'get']); echo \html_writer::start_tag('div'); echo \html_writer::empty_tag('input', - array('type' => 'hidden', 'id' => 'completion_dynamic_change', 'name' => 'completion_dynamic_change', 'value' => '0')); + ['type' => 'hidden', 'id' => 'completion_dynamic_change', 'name' => 'completion_dynamic_change', 'value' => '0']); echo \html_writer::end_tag('div'); echo \html_writer::end_tag('form'); } // Course wrapper start. - echo \html_writer::start_tag('div', array('class' => 'course-content')); + echo \html_writer::start_tag('div', ['class' => 'course-content']); // Make sure that section 0 exists (this function will create one if it is missing). course_create_sections_if_missing($course, 0); diff --git a/classes/course_renderer_wrapper.php b/classes/course_renderer_wrapper.php index edb3d59..62b7358 100644 --- a/classes/course_renderer_wrapper.php +++ b/classes/course_renderer_wrapper.php @@ -82,7 +82,7 @@ public function __construct(\core_course_renderer $inner) { * option 'inblock' => true, suggesting to display controls vertically * @return string */ - public function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array()) : string { + public function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = []) : string { // CHANGED ABOVE: Specify section info instead of number. // TODO: // 2020-02-10 MDL-67264 core_course: Begin set up for Activity chooser @@ -108,10 +108,10 @@ public function course_section_add_cm_control($course, $section, $sectionreturn // Retrieve all modules with associated metadata. $modules = get_module_metadata($course, $modnames); // CHANGED: Removed sectionreturn. - $urlparams = array('sectionid' => $section->id); // CHANGED: Used section ID. + $urlparams = ['sectionid' => $section->id]; // CHANGED: Used section ID. // We'll sort resources and activities into two lists. - $activities = array(MOD_CLASS_ACTIVITY => array(), MOD_CLASS_RESOURCE => array()); + $activities = [MOD_CLASS_ACTIVITY => [], MOD_CLASS_RESOURCE => []]; foreach ($modules as $module) { $activityclass = MOD_CLASS_ACTIVITY; @@ -132,27 +132,27 @@ public function course_section_add_cm_control($course, $section, $sectionreturn $stractivitylabel = get_string('addactivitytosection', null, $sectionname); $output = \html_writer::start_tag('div', - array('class' => 'section_add_menus')); // CHANGED: Removed HTML ID--not used? + ['class' => 'section_add_menus']); // CHANGED: Removed HTML ID--not used? if (!$vertical) { - $output .= \html_writer::start_tag('div', array('class' => 'horizontal')); + $output .= \html_writer::start_tag('div', ['class' => 'horizontal']); } if (!empty($activities[MOD_CLASS_RESOURCE])) { - $select = new \url_select($activities[MOD_CLASS_RESOURCE], '', array('' => $straddresource)); + $select = new \url_select($activities[MOD_CLASS_RESOURCE], '', ['' => $straddresource]); // CHANGED LINE ABOVE: Removed form ID. $select->set_help_icon('resources'); - $select->set_label($strresourcelabel, array('class' => 'accesshide')); + $select->set_label($strresourcelabel, ['class' => 'accesshide']); $output .= preg_replace('/\/course\/jumpto.php\b/', '/course/format/multitopic/_course_jumpto.php', $this->inneroutput->render($select)); // CHANGED LINE ABOVE: Use custom script to convert section ID back to section number. } if (!empty($activities[MOD_CLASS_ACTIVITY])) { - $select = new \url_select($activities[MOD_CLASS_ACTIVITY], '', array('' => $straddactivity)); + $select = new \url_select($activities[MOD_CLASS_ACTIVITY], '', ['' => $straddactivity]); // CHANGED LINE ABOVE: Removed form ID. $select->set_help_icon('activities'); - $select->set_label($stractivitylabel, array('class' => 'accesshide')); + $select->set_label($stractivitylabel, ['class' => 'accesshide']); $output .= preg_replace('/\/course\/jumpto.php\b/', '/course/format/multitopic/_course_jumpto.php', $this->inneroutput->render($select)); // CHANGED LINE ABOVE: Use custom script to convert section ID back to section number. @@ -168,23 +168,23 @@ public function course_section_add_cm_control($course, $section, $sectionreturn // Modchooser can be added only for the current course set on the page! $straddeither = get_string('addresourceoractivity'); // The module chooser link. - $modchooser = \html_writer::start_tag('div', array('class' => 'mdl-right')); - $modchooser .= \html_writer::start_tag('div', array('class' => 'section-modchooser')); + $modchooser = \html_writer::start_tag('div', ['class' => 'mdl-right']); + $modchooser .= \html_writer::start_tag('div', ['class' => 'section-modchooser']); $icon = $this->inneroutput->pix_icon('t/add', ''); // CHANGED. - $span = \html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text')); - $modchooser .= \html_writer::tag('span', $icon . $span, array('class' => 'section-modchooser-link')); + $span = \html_writer::tag('span', $straddeither, ['class' => 'section-modchooser-text']); + $modchooser .= \html_writer::tag('span', $icon . $span, ['class' => 'section-modchooser-link']); $modchooser .= \html_writer::end_tag('div'); $modchooser .= \html_writer::end_tag('div'); // Wrap the normal output in a noscript div. $usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault); if ($usemodchooser) { - $output = \html_writer::tag('div', $output, array('class' => 'hiddenifjs addresourcedropdown')); - $modchooser = \html_writer::tag('div', $modchooser, array('class' => 'visibleifjs addresourcemodchooser')); + $output = \html_writer::tag('div', $output, ['class' => 'hiddenifjs addresourcedropdown']); + $modchooser = \html_writer::tag('div', $modchooser, ['class' => 'visibleifjs addresourcemodchooser']); } else { // If the module chooser is disabled, we need to ensure that the dropdowns are shown even if javascript is disabled. - $output = \html_writer::tag('div', $output, array('class' => 'show addresourcedropdown')); - $modchooser = \html_writer::tag('div', $modchooser, array('class' => 'hide addresourcemodchooser')); + $output = \html_writer::tag('div', $output, ['class' => 'show addresourcedropdown']); + $modchooser = \html_writer::tag('div', $modchooser, ['class' => 'hide addresourcemodchooser']); } $output = $this->inner->course_modchooser($modules, $course) . $modchooser . $output; // CHANGED. } diff --git a/classes/courseheader.php b/classes/courseheader.php index c4d3f32..5ddcc0c 100644 --- a/classes/courseheader.php +++ b/classes/courseheader.php @@ -97,7 +97,7 @@ public function output(): string { $o = \html_writer::start_tag('div', [ 'id' => 'course-header-banner', 'style' => "background-image: url('{$this->imageurl}'); " - . "background-position: center {$this->bannerslice}%;" + . "background-position: center {$this->bannerslice}%;", ]); $o .= \html_writer::tag('div', $this->coursename, [ 'id' => 'course-header-banner-text', @@ -106,7 +106,7 @@ public function output(): string { // Output the attribution. $o .= \html_writer::start_tag('p', ['id' => 'course-header-banner_attribution', - 'style' => 'visibility: ' . ($this->imageurl ? 'visible' : 'hidden') . ';']); + 'style' => 'visibility: ' . ($this->imageurl ? 'visible' : 'hidden') . ';', ]); $o .= format_multitopic_image_attribution($this->imagename, $this->authorwithurl, $this->licencecode); $o .= \html_writer::end_tag('p'); diff --git a/classes/global_navigation_wrapper.php b/classes/global_navigation_wrapper.php index 6b9d9b3..99e71e6 100644 --- a/classes/global_navigation_wrapper.php +++ b/classes/global_navigation_wrapper.php @@ -85,7 +85,7 @@ public function __construct(\global_navigation $inner) { * Generates an array of sections and an array of activities for the given course. * * @param \stdClass $course - * @return array Array($sections, $activities) + * @return array [$sections, $activities] */ protected function generate_sections_and_activities(\stdClass $course) : array { global $CFG; @@ -97,7 +97,7 @@ protected function generate_sections_and_activities(\stdClass $course) : array { // For course formats using 'numsections' trim the sections list. // REMOVED. - $activities = array(); + $activities = []; foreach ($sections as $key => $section) { // Clone and unset summary to prevent $SESSION bloat (MDL-31802). @@ -138,7 +138,7 @@ protected function generate_sections_and_activities(\stdClass $course) : array { } } - return array($sections, $activities); + return [$sections, $activities]; } /** @@ -154,7 +154,7 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node list($sections, $activities) = $this->generate_sections_and_activities($course); - $navigationsections = array(); + $navigationsections = []; // ADDED. // Navigation node at level n. // This is a list of the navigation nodes currently at each level, @@ -184,7 +184,7 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node // CHANGED. $sectionname = get_section_name($course, $section); - $url = course_get_url($course, $section, array('navigation' => true)); // CHANGED: Custom call. + $url = course_get_url($course, $section, ['navigation' => true]); // CHANGED: Custom call. // Add multiple nodes per section, one per level as required. // The course node already exists, so we must start below course level. @@ -246,7 +246,7 @@ protected function load_section_activities(\navigation_node $sectionnode, \secti // A static counter for JS function naming. static $legacyonclickcounter = 0; - $activitynodes = array(); + $activitynodes = []; if (empty($activities)) { return $activitynodes; } @@ -270,7 +270,7 @@ protected function load_section_activities(\navigation_node $sectionnode, \secti } // Prepare the default name and url for the node. - $activityname = format_string($activity->name, true, array('context' => \context_module::instance($activity->id))); + $activityname = format_string($activity->name, true, ['context' => \context_module::instance($activity->id)]); $action = new \moodle_url($activity->url); // Check if the onclick property is set (puke!). diff --git a/lib.php b/lib.php index c4fd123..0d25eea 100644 --- a/lib.php +++ b/lib.php @@ -531,7 +531,7 @@ public function supports_ajax() : stdClass { global $COURSE, $USER; if (!isset($USER->onetopic_da)) { - $USER->onetopic_da = array(); + $USER->onetopic_da = []; } if (empty($COURSE)) { @@ -617,7 +617,7 @@ public function ajax_section_move() : array { public function get_default_blocks() : array { return [ BLOCK_POS_LEFT => [], - BLOCK_POS_RIGHT => [] + BLOCK_POS_RIGHT => [], ]; } @@ -640,13 +640,13 @@ public function course_format_options($foreditform = false) : array { // INCLUDED /course/format/periods/lib.php function course_format_options 'periodduration'. 'periodduration' => [ 'default' => null, // CHANGED. - 'type' => PARAM_NOTAGS + 'type' => PARAM_NOTAGS, ], // END INCLUDED. // ADDED. 'collapsible' => [ 'default' => '1', - 'type' => PARAM_ALPHANUM + 'type' => PARAM_ALPHANUM, ], // END ADDED. 'hiddensections' => [ @@ -676,7 +676,7 @@ public function course_format_options($foreditform = false) : array { null => new lang_string('period_undefined', 'format_multitopic'), '1 day' => new lang_string('numday', '', 1), '1 week' => new lang_string('numweek', '', 1), - ]], + ], ], // END ADDED. ], // END INCLUDED. @@ -688,7 +688,7 @@ public function course_format_options($foreditform = false) : array { [ '0' => get_string('no'), '1' => get_string('yes'), - ] + ], ], 'help' => 'collapsibledefault', 'help_component' => 'format_multitopic', @@ -702,8 +702,8 @@ public function course_format_options($foreditform = false) : array { 'element_attributes' => [ [ 0 => new lang_string('hiddensectionscollapsed'), - 1 => new lang_string('hiddensectionsinvisible') - ] + 1 => new lang_string('hiddensectionsinvisible'), + ], ], ], // REMOVED: coursedisplay . @@ -724,7 +724,7 @@ public function course_format_options($foreditform = false) : array { '70%', '71%', '72%', '73%', '74%', '75%', '76%', '77%', '78%', '79%', '80%', '81%', '82%', '83%', '84%', '85%', '86%', '87%', '88%', '89%', '90%', '91%', '92%', '93%', '94%', '95%', '96%', '97%', '98%', '99%', - '100%'] + '100%', ], ], ], // END ADDED. @@ -768,19 +768,19 @@ public function section_format_options($foreditform = false) : array { // INCLUDED /course/format/onetopic/lib.php function section_format_options 'level'. 'level' => [ 'default' => FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC, // CHANGED. - 'type' => PARAM_INT + 'type' => PARAM_INT, ], // END INCLUDED. // INCLUDED /course/format/periods/lib.php function section_format_options 'periodduration'. 'periodduration' => [ 'default' => null, // ADDED. - 'type' => PARAM_NOTAGS + 'type' => PARAM_NOTAGS, ], // END INCLUDED. // ADDED. 'collapsible' => [ 'default' => null, - 'type' => PARAM_ALPHANUM + 'type' => PARAM_ALPHANUM, ], // END ADDED. ]; @@ -796,8 +796,8 @@ public function section_format_options($foreditform = false) : array { [ FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT + 1 => get_string('asprincipal', 'format_multitopic'), // CHANGED. FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT + 2 => get_string('aschild', 'format_multitopic'), // CHANGED. - FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC => get_string('topic') // ADDED. - ] + FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC => get_string('topic'), // ADDED. + ], ], 'help' => 'level', 'help_component' => 'format_multitopic', @@ -824,7 +824,7 @@ public function section_format_options($foreditform = false) : array { '2 week' => new lang_string('numweeks', '', 2), '3 week' => new lang_string('numweeks', '', 3), '4 week' => new lang_string('numweeks', '', 4), - ]], + ], ], // END ADDED. ], // END INCLUDED. @@ -837,7 +837,7 @@ public function section_format_options($foreditform = false) : array { null => new lang_string('default'), '0' => get_string('no'), '1' => get_string('yes'), - ] + ], ], 'help' => 'collapsibleoverride', 'help_component' => 'format_multitopic', @@ -1053,7 +1053,7 @@ public function inplace_editable_render_section_name($section, $linkifneeded = t $displayvalue = $title = html_writer::tag('i', '', ['class' => ($section->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC ? 'icon fa fa-folder-o fa-fw' - : 'icon fa fa-list fa-fw')]) + : 'icon fa fa-list fa-fw'), ]) . ' ' . get_section_name($section->course, $section); // CHANGED. // TODO: Fix collapse icon for AJAX rename, somehow? if ($linkifneeded) { @@ -1061,7 +1061,7 @@ public function inplace_editable_render_section_name($section, $linkifneeded = t $navigation = ($section->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC) || ((($section->collapsible != '') ? $section->collapsible : $course->collapsible) == '0') || !$section->uservisible; // ADDED. - $url = course_get_url($section->course, $section, array('navigation' => $navigation)); // CHANGED. + $url = course_get_url($section->course, $section, ['navigation' => $navigation]); // CHANGED. if ($url && !(empty($CFG->linkcoursesections) && $navigation)) { // CHANGED. $displayvalue = html_writer::link($url, $title); } @@ -1119,7 +1119,7 @@ public function allow_stealth_module_visibility($cm, $section) : bool { * @param int $sr unused * @return null|array any data for the Javascript post-processor (must be json-encodeable) */ - public function section_action($section, $action, $sr): array { + public function section_action($section, $action, $sr) { global $PAGE; // REMOVED: marker. diff --git a/locallib.php b/locallib.php index 09d8a1c..2e5be58 100644 --- a/locallib.php +++ b/locallib.php @@ -39,7 +39,7 @@ function format_multitopic_set_section_visible(int $courseid, \stdClass $section // CHANGED LINE ABOVE: Use sectioninfo, not section number. global $DB; - $resourcestotoggle = array(); + $resourcestotoggle = []; // ADDED. // Fetch section info. $sections = course_get_format($courseid)->fmt_get_sections(); @@ -51,10 +51,10 @@ function format_multitopic_set_section_visible(int $courseid, \stdClass $section $subsection && ($subsection->id == $section->id || $recurse && $subsection->levelsan > $section->levelsan); /* ... */ $subsection = array_key_exists($subsection->nextanyid, $sections) ? $sections[$subsection->nextanyid] : null) { // CHANGED LINES ABOVE: Recurse, if necessary. - course_update_section($courseid, $subsection, array('visible' => $visibility)); // CHANGED: $section -> $subsection . + course_update_section($courseid, $subsection, ['visible' => $visibility]); // CHANGED: $section -> $subsection . // Determine which modules are visible for AJAX update. - $modules = !empty($subsection->sequence) ? explode(',', $subsection->sequence) : array(); + $modules = !empty($subsection->sequence) ? explode(',', $subsection->sequence) : []; // CHANGED LINE ABOVE: $section -> $subsection. if (!empty($modules)) { list($insql, $params) = $DB->get_in_or_equal($modules); @@ -164,13 +164,13 @@ function format_multitopic_move_section_to(\stdClass $course, \stdClass $section foreach ($movedsections as $id => $movedsection) { $position = $movedsection->section; if ($sections[$id]->section !== $position) { - $DB->set_field('course_sections', 'section', -$position, array('id' => $id)); + $DB->set_field('course_sections', 'section', -$position, ['id' => $id]); } } foreach ($movedsections as $id => $movedsection) { $position = $movedsection->section; if ($sections[$id]->section !== $position) { - $DB->set_field('course_sections', 'section', $position, array('id' => $id)); + $DB->set_field('course_sections', 'section', $position, ['id' => $id]); } } // END CHANGED. @@ -230,7 +230,7 @@ function format_multitopic_course_can_delete_section(\stdClass $course, \section } // Make sure user has capability to update course and move sections. $context = \context_course::instance(is_object($course) ? $course->id : $course); - if (!has_all_capabilities(array('moodle/course:movesections', 'moodle/course:update'), $context)) { + if (!has_all_capabilities(['moodle/course:movesections', 'moodle/course:update'], $context)) { return false; } // Make sure user has capability to delete each activity in this section. @@ -287,7 +287,7 @@ function format_multitopic_reorder_sections(array $sections, \stdClass $origin, $parent = null; $prev = null; $found = false; - $appendarray = array(); + $appendarray = []; foreach ($sections as $id => $section) { if ($found) { // Target position already found, extract remaining sections. diff --git a/renderer.php b/renderer.php index 18e3878..8378ebe 100644 --- a/renderer.php +++ b/renderer.php @@ -207,19 +207,19 @@ protected function section_header($section, $course, $onsectionpage, $sectionret 'aria-labelledby' => "sectionid-{$section->id}-title", 'aria-label' => get_section_name($course, $section), // For Sharing Cart. 'data-sectionid' => $section->section, - 'data-sectionreturnid' => $section->section // CHANGED. + 'data-sectionreturnid' => $section->section, // CHANGED. ]); // Create a span that contains the section title to be used to create the keyboard section move menu. - $o .= html_writer::tag('span', get_section_name($course, $section), array('class' => 'hidden sectionname')); + $o .= html_writer::tag('span', get_section_name($course, $section), ['class' => 'hidden sectionname']); // TODO: Remove above line? MDL-68189. $leftcontent = $this->section_left_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); + $o .= html_writer::tag('div', $leftcontent, ['class' => 'left side']); $rightcontent = $this->section_right_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); + $o .= html_writer::tag('div', $rightcontent, ['class' => 'right side']); + $o .= html_writer::start_tag('div', ['class' => 'content']); // REMOVED: section title display rules. Always display the section title. if (true) { @@ -231,7 +231,7 @@ protected function section_header($section, $course, $onsectionpage, $sectionret $o .= $this->section_availability($section); - $o .= html_writer::start_tag('div', array('class' => 'summary')); + $o .= html_writer::start_tag('div', ['class' => 'summary']); if ($section->uservisible || ($section->section == 0)) { // Do not show summary if section is hidden. $o .= $this->format_summary_text($section); @@ -253,7 +253,7 @@ protected function section_header($section, $course, $onsectionpage, $sectionret */ protected function section_edit_control_items($course, $section, $onsectionpage = false) : array { if (!$this->page->user_is_editing()) { - return array(); + return []; } // REMOVED sectionreturn . @@ -267,7 +267,7 @@ protected function section_edit_control_items($course, $section, $onsectionpage $baseurl = course_get_url($course, $section, ['fmtedit' => true]); // CHANGED. $baseurl->param('sesskey', sesskey()); - $controls = array(); + $controls = []; if (!$isstealth && has_capability('moodle/course:update', $coursecontext)) { if ($section->section > 0 @@ -277,13 +277,13 @@ protected function section_edit_control_items($course, $section, $onsectionpage $streditsection = get_string('editsection'); } - $controls['edit'] = array( + $controls['edit'] = [ 'url' => new moodle_url('/course/format/multitopic/_course_editsection.php', - array('id' => $section->id)), // CHANGED. + ['id' => $section->id]), // CHANGED. 'icon' => 'i/settings', 'name' => $streditsection, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon edit')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon edit'], ]; } if ($section->section) { @@ -295,13 +295,13 @@ protected function section_edit_control_items($course, $section, $onsectionpage get_string('hidefromothers', 'format_' . $course->format) : get_string('hide'); // CHANGED. $url->param('hideid', $section->id); // CHANGED. - $controls['visiblity'] = array( + $controls['visiblity'] = [ 'url' => $url, 'icon' => 'i/hide', 'name' => $strhidefromothers, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon editing_showhide', - )); // REMOVED section return & AJAX action . + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon editing_showhide', + ], ]; // REMOVED section return & AJAX action . // ADDED: AJAX action added back for topic-level sections only. if (!$onsectionpage) { $controls['visiblity']['attr']['data-action'] = 'hide'; @@ -312,13 +312,13 @@ protected function section_edit_control_items($course, $section, $onsectionpage get_string('showfromothers', 'format_' . $course->format) : get_string('show'); // CHANGED. $url->param('showid', $section->id); // CHANGED. - $controls['visiblity'] = array( + $controls['visiblity'] = [ 'url' => $url, 'icon' => 'i/show', 'name' => $strshowfromothers, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon editing_showhide', - )); // REMOVED section return & AJAX action. + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon editing_showhide', + ], ]; // REMOVED section return & AJAX action. // ADDED: AJAX action added back for topic-level sections only. if (!$onsectionpage) { $controls['visiblity']['attr']['data-action'] = 'show'; @@ -341,12 +341,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $strmovelevelup = get_string_manager()->string_exists('move_level_up', 'format_multitopic') ? get_string('move_level_up', 'format_multitopic') : get_string('moveup'); // END CHANGED. - $controls['movelevelup'] = array( // CHANGED. + $controls['movelevelup'] = [ // CHANGED. 'url' => $url, 'icon' => 'i/up', 'name' => $strmovelevelup, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmovelevelup')); // CHANGED. + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmovelevelup'], ]; // CHANGED. } $url = clone($baseurl); @@ -358,12 +358,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $strmoveleveldown = get_string_manager()->string_exists('move_level_down', 'format_multitopic') ? get_string('move_level_down', 'format_multitopic') : get_string('movedown'); // END CHANGED. - $controls['moveleveldown'] = array( // CHANGED. + $controls['moveleveldown'] = [ // CHANGED. 'url' => $url, 'icon' => 'i/down', 'name' => $strmoveleveldown, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmoveleveldown')); // CHANGED. + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmoveleveldown'], ]; // CHANGED. } } if (has_capability('moodle/course:movesections', $coursecontext) @@ -376,12 +376,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('destnextupid', $section->prevupid); $strmovepageprev = get_string_manager()->string_exists('move_page_prev', 'format_multitopic') ? get_string('move_page_prev', 'format_multitopic') : get_string('moveleft'); - $controls['moveprev'] = array( + $controls['moveprev'] = [ 'url' => $url, 'icon' => 't/left', 'name' => $strmovepageprev, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmovepageprev')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmovepageprev'], ]; } // END CHANGED. @@ -392,12 +392,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('destprevupid', $section->nextupid); $strmovepagenext = get_string_manager()->string_exists('move_page_next', 'format_multitopic') ? get_string('move_page_next', 'format_multitopic') : get_string('moveright'); - $controls['movenext'] = array( + $controls['movenext'] = [ 'url' => $url, 'icon' => 't/right', 'name' => $strmovepagenext, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmovepagenext')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmovepagenext'], ]; } // END CHANGED. } @@ -412,12 +412,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('destparentid', $section->prevpageid); $strmovetoprevpage = get_string_manager()->string_exists('move_to_prev_page', 'format_multitopic') ? get_string('move_to_prev_page', 'format_multitopic') : get_string('moveleft'); - $controls['movetoprevpage'] = array( + $controls['movetoprevpage'] = [ 'url' => $url, 'icon' => 't/left', 'name' => $strmovetoprevpage, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmovetoprevpage')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmovetoprevpage'], ]; } // END CHANGED. @@ -428,12 +428,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('destparentid', $section->nextpageid); $strmovetonextpage = get_string_manager()->string_exists('move_to_next_page', 'format_multitopic') ? get_string('move_to_next_page', 'format_multitopic') : get_string('moveright'); - $controls['movetonextpage'] = array( + $controls['movetonextpage'] = [ 'url' => $url, 'icon' => 't/right', 'name' => $strmovetonextpage, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon fmtmovetonextpage')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon fmtmovetonextpage'], ]; } // END CHANGED. @@ -445,12 +445,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('sectionid', $section->id); $url->param('destnextupid', $section->prevupid); $strmoveup = get_string('moveup'); - $controls['moveup'] = array( + $controls['moveup'] = [ 'url' => $url, 'icon' => 'i/up', 'name' => $strmoveup, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon moveup')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon moveup'], ]; } $url = clone($baseurl); @@ -459,12 +459,12 @@ protected function section_edit_control_items($course, $section, $onsectionpage $url->param('sectionid', $section->id); $url->param('destprevupid', $section->nextupid); $strmovedown = get_string('movedown'); - $controls['movedown'] = array( + $controls['movedown'] = [ 'url' => $url, 'icon' => 'i/down', 'name' => $strmovedown, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon movedown')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon movedown'], ]; } } } @@ -476,17 +476,17 @@ protected function section_edit_control_items($course, $section, $onsectionpage } else { $strdelete = get_string('deletesection'); } - $url = new moodle_url('/course/format/multitopic/_course_editsection.php', array( + $url = new moodle_url('/course/format/multitopic/_course_editsection.php', [ 'id' => $section->id, // REMOVED: section return. 'delete' => 1, - 'sesskey' => sesskey())); - $controls['delete'] = array( + 'sesskey' => sesskey(), ]); + $controls['delete'] = [ 'url' => $url, 'icon' => 'i/delete', 'name' => $strdelete, - 'pixattr' => array('class' => ''), - 'attr' => array('class' => 'icon editing_delete')); + 'pixattr' => ['class' => ''], + 'attr' => ['class' => 'icon editing_delete'], ]; } } @@ -557,16 +557,16 @@ protected function fmt_course_activity_clipboard(stdClass $course, section_info // Output the clipboard itself. if ($disableajax || ismoving($course->id)) { // TODO: Also show when JS disabled? - $o .= html_writer::start_tag('div', array('class' => 'clipboard')); + $o .= html_writer::start_tag('div', ['class' => 'clipboard']); $o .= html_writer::tag('i', '', ['class' => 'icon fa fa-clipboard fa-fw']) . ' '; // If currently moving a file then show the current clipboard. if (ismoving($course->id)) { $url = new moodle_url('/course/mod.php', - array('sesskey' => sesskey(), + ['sesskey' => sesskey(), 'cancelcopy' => true, // REMOVED section return. - ) + ] ); $o .= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname)); @@ -669,8 +669,8 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames // and /course/format/onetopic/renderer.php function print_single_section_page tabs parts CHANGED. // Init custom tabs. - $tabs = array(); - $inactivetabs = array(); + $tabs = []; + $inactivetabs = []; $tabln = array_fill(FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT + 1, FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC - FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT - 1, null); @@ -713,7 +713,7 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames . ($thissection->currentnestedlevel >= $level ? ' marker' : '') . ((!$thissection->visible || !$thissection->available) && ($thissection->section != 0) || $level > $thissection->pagedepthdirect ? ' dimmed' : ''), - 'data-itemid' => $thissection->id + 'data-itemid' => $thissection->id, ]), $sectionname); $newtab->level = $level - FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT; @@ -805,11 +805,11 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames $thissection = $thissection->nextanyid ? $sections[$thissection->nextanyid] : null; } echo html_writer::start_tag('div', - array('class' => 'collapsible-actions', 'style' => $collapsiblenum ? '' : 'display: none;')); + ['class' => 'collapsible-actions', 'style' => $collapsiblenum ? '' : 'display: none;']); echo html_writer::tag('a', get_string('expandall'), - array('href' => '#', 'class' => 'collapseexpand expand-all', 'role' => 'button')); + ['href' => '#', 'class' => 'collapseexpand expand-all', 'role' => 'button']); echo html_writer::tag('a', get_string('collapseall'), - array('href' => '#', 'class' => 'collapseexpand collapse-all', 'role' => 'button', 'style' => 'display: none;')); + ['href' => '#', 'class' => 'collapseexpand collapse-all', 'role' => 'button', 'style' => 'display: none;']); echo html_writer::end_tag('div'); // END ADDED. @@ -918,7 +918,7 @@ protected function change_number_sections($course, $sectionreturn = null, stdCla // Note to course format developers: inserting sections in the other positions should check both // capabilities 'moodle/course:update' and 'moodle/course:movesections'. $o = ''; - $o .= html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right')); + $o .= html_writer::start_tag('div', ['id' => 'changenumsections', 'class' => 'mdl-right']); if (get_string_manager()->string_exists('addsectiontopic', 'format_' . $course->format)) { $straddsections = get_string('addsectiontopic', 'format_' . $course->format); } else { diff --git a/settings.php b/settings.php index a18dd4e..9705f26 100644 --- a/settings.php +++ b/settings.php @@ -36,7 +36,7 @@ 0 => new lang_string('sunday', 'calendar'), 1 => new lang_string('monday', 'calendar'), 5 => new lang_string('friday', 'calendar'), - 6 => new lang_string('saturday', 'calendar') + 6 => new lang_string('saturday', 'calendar'), ] )); diff --git a/version.php b/version.php index e4a3539..1d7a0e7 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022053000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022053002; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2017051500; // Requires this Moodle version. $plugin->component = 'format_multitopic'; // Full name of the plugin (used for diagnostics). // CHANGED: format name. -$plugin->maturity = MATURITY_RC; -$plugin->release = 'v3.2.2-rc1'; +$plugin->maturity = MATURITY_STABLE; +$plugin->release = 'v3.2.2';