Skip to content

Commit

Permalink
Merge branch 'code_checker_updates_2023-10_moodle_35' into check_mood…
Browse files Browse the repository at this point in the history
…le_old_2
  • Loading branch information
james-cnz committed Oct 3, 2023
2 parents 7cae3e7 + 3e3eaf9 commit 0fb6bde
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 166 deletions.
44 changes: 21 additions & 23 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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'
ports:
- 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"
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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() }}
Expand Down
8 changes: 4 additions & 4 deletions _course_changenumsections.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions _course_editsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'));
Expand All @@ -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;
Expand All @@ -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.
Expand Down
28 changes: 14 additions & 14 deletions _course_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
34 changes: 17 additions & 17 deletions classes/course_renderer_wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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.
Expand All @@ -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.
}
Expand Down
4 changes: 2 additions & 2 deletions classes/courseheader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');

Expand Down
Loading

0 comments on commit 0fb6bde

Please sign in to comment.