From 954e906271ce1419f968c060309095b923032750 Mon Sep 17 00:00:00 2001 From: ewallah Date: Sat, 9 Dec 2023 15:19:01 +0100 Subject: [PATCH 1/3] Depricated creation of dynamic property course Deprecated: Creation of dynamic property block_completion_progress\overview_test::$course is deprecated in blocks/completion_progress/tests/overview_test.php on line 78 --- tests/overview_test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/overview_test.php b/tests/overview_test.php index 30b264f83f..1c07af8e2e 100644 --- a/tests/overview_test.php +++ b/tests/overview_test.php @@ -42,6 +42,12 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class overview_test extends \advanced_testcase { + /** + * Course. + * @var object + */ + private $course; + /** * Teacher users. * @var array From ea3620c5b085d61ca29398e33bd8e9cb4567a72f Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Sat, 9 Dec 2023 15:46:01 +0100 Subject: [PATCH 2/3] short dates when downloading --- .github/workflows/ci.yml | 2 +- classes/table/overview.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ec57e815e..9ccc24b8f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - name: Deploy 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 ^4 echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH sudo locale-gen en_AU.UTF-8 diff --git a/classes/table/overview.php b/classes/table/overview.php index da9e3c385e..55e1b6a0c7 100644 --- a/classes/table/overview.php +++ b/classes/table/overview.php @@ -72,6 +72,7 @@ public function __construct(completion_progress $progress, $groups, $roleid, $bu $this->progress = $progress; $this->output = $PAGE->get_renderer('block_completion_progress'); $this->strs['strftimedaydatetime'] = get_string('strftimedaydatetime', 'langconfig'); + $this->strs['strftimedatetimeshort'] = get_string('strftimedatetimeshort', 'langconfig'); $this->strs['indeterminate'] = get_string('indeterminate', 'block_completion_progress'); $this->strs['never'] = get_string('never'); @@ -279,7 +280,7 @@ public function col_timeaccess($row) { if ($row->timeaccess == 0) { return $this->strs['never']; } - return userdate($row->timeaccess, $this->strs['strftimedaydatetime']); + return userdate($row->timeaccess, $this->strs[$this->is_downloading() ? 'strftimedatetimeshort' : 'strftimedaydatetime']); } /** From ee5719aafe93c91b7c21746c03711c31977c62ae Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Sat, 9 Dec 2023 16:03:34 +0100 Subject: [PATCH 3/3] code review --- ...e_completion_progress_block_task.class.php | 16 ++--- block_completion_progress.php | 16 ++--- classes/completion_progress.php | 4 +- classes/output/renderer.php | 66 +++++++++---------- css.php | 6 +- db/access.php | 46 ++++++------- edit_form.php | 24 +++---- overview.php | 28 ++++---- settings.php | 12 ++-- tests/assign_completion_test.php | 8 +-- tests/general_test.php | 12 +++- tests/overview_test.php | 6 +- tests/quiz_completion_test.php | 8 +-- tests/workshop_completion_test.php | 4 +- 14 files changed, 131 insertions(+), 125 deletions(-) diff --git a/backup/moodle2/restore_completion_progress_block_task.class.php b/backup/moodle2/restore_completion_progress_block_task.class.php index 3534b6fd37..5b96470aae 100644 --- a/backup/moodle2/restore_completion_progress_block_task.class.php +++ b/backup/moodle2/restore_completion_progress_block_task.class.php @@ -43,15 +43,15 @@ public function after_restore() { // Get restored course id. $courseid = $this->get_courseid(); - if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $id))) { + if ($configdata = $DB->get_field('block_instances', 'configdata', ['id' => $id])) { $config = (array)unserialize(base64_decode($configdata)); - $newactivities = array(); + $newactivities = []; $newgroup = '0'; if (isset($config['selectactivities'])) { // Translate the old config information to the target course values. foreach ($config['selectactivities'] as $value) { - $matches = array(); + $matches = []; preg_match('/(.+)-(\d+)/', $value, $matches); if (!empty($matches)) { $module = $matches[1]; @@ -88,7 +88,7 @@ public function after_restore() { $config['selectactivities'] = $newactivities; $config['group'] = $newgroup; $configdata = base64_encode(serialize((object)$config)); - $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $id)); + $DB->set_field('block_instances', 'configdata', $configdata, ['id' => $id]); } } @@ -110,7 +110,7 @@ protected function define_my_steps() { * @return array An empty array */ public function get_fileareas() { - return array(); + return []; } /** @@ -119,7 +119,7 @@ public function get_fileareas() { * @return array An empty array */ public function get_configdata_encoded_attributes() { - return array(); + return []; } /** @@ -128,7 +128,7 @@ public function get_configdata_encoded_attributes() { * @return array An empty array */ public static function define_decode_contents() { - return array(); + return []; } /** @@ -137,6 +137,6 @@ public static function define_decode_contents() { * @return array An empty array */ public static function define_decode_rules() { - return array(); + return []; } } diff --git a/block_completion_progress.php b/block_completion_progress.php index b8181f42c6..19e454462e 100644 --- a/block_completion_progress.php +++ b/block_completion_progress.php @@ -94,12 +94,12 @@ public function instance_allow_config() { * @return array */ public function applicable_formats() { - return array( + return [ 'course-view' => true, 'site' => true, 'mod' => false, - 'my' => true - ); + 'my' => true, + ]; } /** @@ -115,7 +115,7 @@ public function get_content() { $this->content = new stdClass; $this->content->text = ''; $this->content->footer = ''; - $barinstances = array(); + $barinstances = []; // Guests do not have any progress. Don't show them the block. if (!isloggedin() || isguestuser()) { @@ -213,7 +213,7 @@ protected function prepare_dashboard_content(&$barinstances) { // Output the Progress Bar. if (!empty($blockprogresses)) { - $courselink = new moodle_url('/course/view.php', array('id' => $course->id)); + $courselink = new moodle_url('/course/view.php', ['id' => $course->id]); $linktext = html_writer::tag('h3', s(format_string($course->$coursenametoshow))); $this->content->text .= html_writer::link($courselink, $linktext); } @@ -286,14 +286,14 @@ protected function prepare_course_content(&$barinstances) { if (has_capability('block/completion_progress:showbar', $this->context)) { $this->content->text .= $output->render($progress); } - $barinstances = array($this->instance->id); + $barinstances = [$this->instance->id]; // Allow teachers to access the overview page. if (has_capability('block/completion_progress:overview', $this->context)) { - $parameters = array('instanceid' => $this->instance->id, 'courseid' => $COURSE->id); + $parameters = ['instanceid' => $this->instance->id, 'courseid' => $COURSE->id]; $url = new moodle_url('/blocks/completion_progress/overview.php', $parameters); $label = get_string('overview', 'block_completion_progress'); - $options = array('class' => 'overviewButton'); + $options = ['class' => 'overviewButton']; $this->content->text .= $OUTPUT->single_button($url, $label, 'get', $options); } diff --git a/classes/completion_progress.php b/classes/completion_progress.php index d1dc825189..3fc00e0f1d 100644 --- a/classes/completion_progress.php +++ b/classes/completion_progress.php @@ -622,7 +622,7 @@ protected function load_submissions() { } // Queries to deliver instance IDs of activities with submissions by user. - $queries = array ( + $queries = [ [ // Assignments with individual submission, or groups requiring a submission per user, // or ungrouped users in a group submission situation. @@ -736,7 +736,7 @@ protected function load_submissions() { 'gmavg' => QUIZ_GRADEAVERAGE, ], ], - ); + ]; $this->submissions = []; foreach ($queries as $spec) { diff --git a/classes/output/renderer.php b/classes/output/renderer.php index e90963a66c..1ca18209a7 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -63,25 +63,25 @@ public function render_completion_progress(completion_progress $progress) { return get_string('no_visible_activities_message', 'block_completion_progress'); } - $alternatelinks = array( - 'assign' => array( + $alternatelinks = [ + 'assign' => [ 'url' => '/mod/assign/view.php?id=:cmid&action=grade&userid=:userid', 'capability' => 'mod/assign:grade', - ), - 'feedback' => array( + ], + 'feedback' => [ // Breaks if anonymous feedback is collected. 'url' => '/mod/feedback/show_entries.php?id=:cmid&do_show=showoneentry&userid=:userid', 'capability' => 'mod/feedback:viewreports', - ), - 'lesson' => array( + ], + 'lesson' => [ 'url' => '/mod/lesson/report.php?id=:cmid&action=reportdetail&userid=:userid', 'capability' => 'mod/lesson:viewreports', - ), - 'quiz' => array( + ], + 'quiz' => [ 'url' => '/mod/quiz/report.php?id=:cmid&mode=overview', 'capability' => 'mod/quiz:viewreports', - ), - ); + ], + ]; // Get relevant block instance settings or use defaults. if (get_config('block_completion_progress', 'forceiconsinbar') == 0) { @@ -97,9 +97,9 @@ public function render_completion_progress(completion_progress $progress) { $displaynow = $orderby == completion_progress::ORDERBY_TIME; $showpercentage = $config->showpercentage ?? defaults::SHOWPERCENTAGE; - $rowoptions = array('style' => ''); - $cellsoptions = array('style' => ''); - $barclasses = array('barRow'); + $rowoptions = ['style' => '']; + $cellsoptions = ['style' => '']; + $barclasses = ['barRow']; $content .= html_writer::start_div('barContainer', ['data-instanceid' => $instance]); @@ -120,10 +120,10 @@ public function render_completion_progress(completion_progress $progress) { $displaynow = false; } if ($longbars == 'scroll') { - $leftpoly = html_writer::tag('polygon', '', array('points' => '30,0 0,15 30,30', 'class' => 'triangle-polygon')); - $rightpoly = html_writer::tag('polygon', '', array('points' => '0,0 30,15 0,30', 'class' => 'triangle-polygon')); - $content .= html_writer::tag('svg', $leftpoly, array('class' => 'left-arrow-svg', 'height' => '30', 'width' => '30')); - $content .= html_writer::tag('svg', $rightpoly, array('class' => 'right-arrow-svg', 'height' => '30', 'width' => '30')); + $leftpoly = html_writer::tag('polygon', '', ['points' => '30,0 0,15 30,30', 'class' => 'triangle-polygon']); + $rightpoly = html_writer::tag('polygon', '', ['points' => '0,0 30,15 0,30', 'class' => 'triangle-polygon']); + $content .= html_writer::tag('svg', $leftpoly, ['class' => 'left-arrow-svg', 'height' => '30', 'width' => '30']); + $content .= html_writer::tag('svg', $rightpoly, ['class' => 'right-arrow-svg', 'height' => '30', 'width' => '30']); } $barclasses[] = 'barMode' . ucfirst($longbars); if ($useicons) { @@ -141,8 +141,8 @@ public function render_completion_progress(completion_progress $progress) { $nowpos++; } $nowstring = get_string('now_indicator', 'block_completion_progress'); - $leftarrowimg = $this->pix_icon('left', $nowstring, 'block_completion_progress', array('class' => 'nowicon')); - $rightarrowimg = $this->pix_icon('right', $nowstring, 'block_completion_progress', array('class' => 'nowicon')); + $leftarrowimg = $this->pix_icon('left', $nowstring, 'block_completion_progress', ['class' => 'nowicon']); + $rightarrowimg = $this->pix_icon('right', $nowstring, 'block_completion_progress', ['class' => 'nowicon']); } // Determine links to activities. @@ -151,12 +151,12 @@ public function render_completion_progress(completion_progress $progress) { array_key_exists($activities[$i]->type, $alternatelinks) && has_capability($alternatelinks[$activities[$i]->type]['capability'], $activities[$i]->context) ) { - $substitutions = array( + $substitutions = [ '/:courseid/' => $courseid, '/:eventid/' => $activities[$i]->instance, '/:cmid/' => $activities[$i]->id, '/:userid/' => $userid, - ); + ]; $link = $alternatelinks[$activities[$i]->type]['url']; $link = preg_replace(array_keys($substitutions), array_values($substitutions), $link); $activities[$i]->link = $CFG->wwwroot.$link; @@ -174,10 +174,10 @@ public function render_completion_progress(completion_progress $progress) { // A cell in the progress bar. $cellcontent = ''; - $celloptions = array( + $celloptions = [ 'class' => 'progressBarCell', 'data-info-ref' => 'progressBarInfo'.$instance.'-'.$userid.'-'.$activity->id, - ); + ]; if ($complete === 'submitted') { $celloptions['class'] .= ' submittedNotComplete'; @@ -229,20 +229,20 @@ public function render_completion_progress(completion_progress $progress) { if ($showpercentage && !$simple) { $progress = $progress->get_percentage(); $percentagecontent = get_string('progress', 'block_completion_progress').': '.$progress.'%'; - $percentageoptions = array('class' => 'progressPercentage'); + $percentageoptions = ['class' => 'progressPercentage']; $content .= html_writer::tag('div', $percentagecontent, $percentageoptions); } // Add the info box below the table. - $divoptions = array('class' => 'progressEventInfo', - 'id' => 'progressBarInfo'.$instance.'-'.$userid.'-info'); + $divoptions = ['class' => 'progressEventInfo', + 'id' => 'progressBarInfo'.$instance.'-'.$userid.'-info']; $content .= html_writer::start_tag('div', $divoptions); if (!$simple) { $content .= get_string('mouse_over_prompt', 'block_completion_progress'); $content .= ' '; - $attributes = array ( + $attributes = [ 'class' => 'accesshide progressShowAllInfo', - ); + ]; $content .= html_writer::link('#', get_string('showallinfo', 'block_completion_progress'), $attributes); } $content .= html_writer::end_tag('div'); @@ -258,14 +258,14 @@ public function render_completion_progress(completion_progress $progress) { foreach ($activities as $activity) { $completed = $completions[$activity->id] ?? null; - $divoptions = array('class' => 'progressEventInfo', + $divoptions = ['class' => 'progressEventInfo', 'id' => 'progressBarInfo'.$instance.'-'.$userid.'-'.$activity->id, - 'style' => 'display: none;'); + 'style' => 'display: none;']; $content .= html_writer::start_tag('div', $divoptions); $text = ''; $text .= html_writer::empty_tag('img', - array('src' => $activity->icon, 'class' => 'moduleIcon', 'alt' => '', 'role' => 'presentation')); + ['src' => $activity->icon, 'class' => 'moduleIcon', 'alt' => '', 'role' => 'presentation']); $text .= $activity->name; if (!empty($activity->link) && (!empty($activity->available) || $simple)) { $attrs = ['class' => 'action_link']; @@ -299,10 +299,10 @@ public function render_completion_progress(completion_progress $progress) { $altattribute .= '(' . $strsubmitted . ')'; } } - $content .= $this->pix_icon($icon, $altattribute, 'block_completion_progress', array('class' => 'iconInInfo')); + $content .= $this->pix_icon($icon, $altattribute, 'block_completion_progress', ['class' => 'iconInInfo']); $content .= html_writer::empty_tag('br'); if ($activity->expected != 0) { - $content .= html_writer::start_tag('div', array('class' => 'expectedBy')); + $content .= html_writer::start_tag('div', ['class' => 'expectedBy']); $content .= $strtimeexpected.': '; $content .= userdate($activity->expected, $strdateformat, $CFG->timezone); $content .= html_writer::end_tag('div'); diff --git a/css.php b/css.php index 85bc397bae..d0677a9065 100644 --- a/css.php +++ b/css.php @@ -34,12 +34,12 @@ $css = ''; // Emit colours configuration. -$colours = array( +$colours = [ 'completed' => 'completed_colour', 'submittedNotComplete' => 'submittednotcomplete_colour', 'notCompleted' => 'notCompleted_colour', - 'futureNotCompleted' => 'futureNotCompleted_colour' -); + 'futureNotCompleted' => 'futureNotCompleted_colour', +]; foreach ($colours as $classname => $stringkey) { $colour = get_config('block_completion_progress', $stringkey) ?: get_string($stringkey, 'block_completion_progress'); diff --git a/db/access.php b/db/access.php index 623cfe24b5..f61f0fb6cb 100644 --- a/db/access.php +++ b/db/access.php @@ -24,50 +24,50 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array ( - 'block/completion_progress:overview' => array ( +$capabilities = [ + 'block/completion_progress:overview' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array ( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, - 'coursecreator' => CAP_ALLOW - ) - ), + 'coursecreator' => CAP_ALLOW, + ], + ], - 'block/completion_progress:showbar' => array ( + 'block/completion_progress:showbar' => [ 'captype' => 'read', 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array ( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, 'student' => CAP_ALLOW, - ) - ), + ], + ], - 'block/completion_progress:addinstance' => array( + 'block/completion_progress:addinstance' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'write', 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, - 'coursecreator' => CAP_ALLOW - ), + 'coursecreator' => CAP_ALLOW, + ], - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ), + 'clonepermissionsfrom' => 'moodle/site:manageblocks', + ], - 'block/completion_progress:myaddinstance' => array( + 'block/completion_progress:myaddinstance' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), + 'archetypes' => [ + 'user' => CAP_ALLOW, + ], - 'clonepermissionsfrom' => 'moodle/my:manageblocks' - ), -); + 'clonepermissionsfrom' => 'moodle/my:manageblocks', + ], +]; diff --git a/edit_form.php b/edit_form.php index 6e2c4a1372..4d6b08090e 100644 --- a/edit_form.php +++ b/edit_form.php @@ -57,12 +57,12 @@ protected function specific_definition($mform) { // Control order of items in Progress Bar. $expectedbystring = get_string('completionexpected', 'completion'); - $options = array( + $options = [ completion_progress::ORDERBY_TIME => get_string('config_orderby_due_time', 'block_completion_progress', $expectedbystring), completion_progress::ORDERBY_COURSE => get_string('config_orderby_course_order', 'block_completion_progress'), - ); + ]; $label = get_string('config_orderby', 'block_completion_progress'); $mform->addElement('select', 'config_orderby', $label, $options); $mform->setDefault('config_orderby', defaults::ORDERBY); @@ -78,16 +78,16 @@ protected function specific_definition($mform) { } if (!$allwithexpected) { $warningstring = get_string('not_all_expected_set', 'block_completion_progress', $expectedbystring); - $expectedwarning = html_writer::tag('div', $warningstring, array('class' => 'warning')); + $expectedwarning = html_writer::tag('div', $warningstring, ['class' => 'warning']); $mform->addElement('static', $expectedwarning, '', $expectedwarning); } // Control how long bars wrap/scroll. - $options = array( + $options = [ 'squeeze' => get_string('config_squeeze', 'block_completion_progress'), 'scroll' => get_string('config_scroll', 'block_completion_progress'), 'wrap' => get_string('config_wrap', 'block_completion_progress'), - ); + ]; $label = get_string('config_longbars', 'block_completion_progress'); $mform->addElement('select', 'config_longbars', $label, $options); $defaultlongbars = get_config('block_completion_progress', 'defaultlongbars') ?: defaults::LONGBARS; @@ -98,8 +98,8 @@ protected function specific_definition($mform) { if (get_config('block_completion_progress', 'forceiconsinbar') !== "1") { $mform->addElement('selectyesno', 'config_progressBarIcons', get_string('config_icons', 'block_completion_progress').' '. - $OUTPUT->pix_icon('tick', '', 'block_completion_progress', array('class' => 'iconOnConfig')). - $OUTPUT->pix_icon('cross', '', 'block_completion_progress', array('class' => 'iconOnConfig'))); + $OUTPUT->pix_icon('tick', '', 'block_completion_progress', ['class' => 'iconOnConfig']). + $OUTPUT->pix_icon('cross', '', 'block_completion_progress', ['class' => 'iconOnConfig'])); $mform->setDefault('config_progressBarIcons', defaults::PROGRESSBARICONS); $mform->addHelpButton('config_progressBarIcons', 'why_use_icons', 'block_completion_progress'); } @@ -114,7 +114,7 @@ protected function specific_definition($mform) { $groups = groups_get_all_groups($COURSE->id); $groupings = groups_get_all_groupings($COURSE->id); if (!empty($groups) || !empty($groupings)) { - $options = array(); + $options = []; $options['0'] = get_string('allparticipants'); foreach ($groups as $group) { $options['group-' . $group->id] = format_string($group->name); @@ -138,10 +138,10 @@ protected function specific_definition($mform) { $mform->setAdvanced('config_progressTitle', true); // Control which activities are included in the bar. - $options = array( + $options = [ 'activitycompletion' => get_string('config_activitycompletion', 'block_completion_progress'), 'selectedactivities' => get_string('config_selectedactivities', 'block_completion_progress'), - ); + ]; $label = get_string('config_activitiesincluded', 'block_completion_progress'); $mform->addElement('select', 'config_activitiesincluded', $label, $options); $mform->setDefault('config_activitiesincluded', defaults::ACTIVITIESINCLUDED); @@ -151,10 +151,10 @@ protected function specific_definition($mform) { // Check that there are activities to monitor. if (empty($activities)) { $warningstring = get_string('no_activities_config_message', 'block_completion_progress'); - $activitieswarning = html_writer::tag('div', $warningstring, array('class' => 'warning')); + $activitieswarning = html_writer::tag('div', $warningstring, ['class' => 'warning']); $mform->addElement('static', '', '', $activitieswarning); } else { - $options = array(); + $options = []; foreach ($activities as $activity) { $options[$activity->type.'-'.$activity->instance] = format_string($activity->name); } diff --git a/overview.php b/overview.php index 6b5fc560b1..b90153d96a 100644 --- a/overview.php +++ b/overview.php @@ -50,11 +50,11 @@ $download = optional_param('download', '', PARAM_ALPHA); // Determine course and context. -$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); +$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); $context = context_course::instance($courseid); // Get specific block config and context. -$block = $DB->get_record('block_instances', array('id' => $id), '*', MUST_EXIST); +$block = $DB->get_record('block_instances', ['id' => $id], '*', MUST_EXIST); $blockcontext = context_block::instance($id); $notesallowed = !empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context); @@ -65,14 +65,14 @@ $PAGE->set_course($course); $PAGE->set_url( '/blocks/completion_progress/overview.php', - array( + [ 'instanceid' => $id, 'courseid' => $courseid, 'page' => $page, 'perpage' => $perpage, 'group' => $group, 'role' => $role, - ) + ] ); $PAGE->set_context($context); $title = get_string('overview', 'block_completion_progress'); @@ -131,7 +131,7 @@ ORDER BY r.sortorder"; $params = ['contextid' => $context->id]; $roles = role_fix_names($DB->get_records_sql($sql, $params), $context); -$roleoptions = array(0 => get_string('allparticipants')); +$roleoptions = [0 => get_string('allparticipants')]; foreach ($roles as $rec) { if ($role === null && $rec->archetype === 'student') { $role = $rec->id; // First student role is the default. @@ -182,12 +182,12 @@ echo $output->container_end(); // Form for messaging selected participants. -$formattributes = array('action' => $CFG->wwwroot.'/user/action_redir.php', 'method' => 'post', 'id' => 'participantsform'); +$formattributes = ['action' => $CFG->wwwroot.'/user/action_redir.php', 'method' => 'post', 'id' => 'participantsform']; $formattributes['data-course-id'] = $course->id; $formattributes['data-table-unique-id'] = 'block-completion_progress-overview-' . $course->id; echo html_writer::start_tag('form', $formattributes); -echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); -echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'returnto', 'value' => s($PAGE->url->out(false)))); +echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]); +echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'returnto', 'value' => s($PAGE->url->out(false))]); // Imitate a 3.9 dynamic table enough to fool the core_user/participants JS code, until // next time it changes again. @@ -211,18 +211,18 @@ if ($perpage < SHOW_ALL_PAGE_SIZE) { $perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE); echo $output->container(html_writer::link($perpageurl, - get_string('showall', '', $table->totalrows)), array(), 'showall'); + get_string('showall', '', $table->totalrows)), [], 'showall'); } else { $perpageurl->param('perpage', DEFAULT_PAGE_SIZE); echo $output->container(html_writer::link($perpageurl, - get_string('showperpage', '', DEFAULT_PAGE_SIZE)), array(), 'showall'); + get_string('showperpage', '', DEFAULT_PAGE_SIZE)), [], 'showall'); } } if ($bulkoperations) { echo '
'; - $displaylist = array(); + $displaylist = []; if ($messagingallowed) { $displaylist['#messageselect'] = get_string('messageselectadd'); } @@ -230,8 +230,8 @@ $displaylist['#addgroupnote'] = get_string('addnewnote', 'notes'); } - echo html_writer::tag('label', get_string("withselectedusers"), array('for' => 'formactionid')); - echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid')); + echo html_writer::tag('label', get_string("withselectedusers"), ['for' => 'formactionid']); + echo html_writer::select($displaylist, 'formaction', '', ['' => 'choosedots'], ['id' => 'formactionid']); echo ''; echo '