Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions backup/moodle2/restore_completion_progress_block_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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]);
}
}

Expand All @@ -110,7 +110,7 @@ protected function define_my_steps() {
* @return array An empty array
*/
public function get_fileareas() {
return array();
return [];
}

/**
Expand All @@ -119,7 +119,7 @@ public function get_fileareas() {
* @return array An empty array
*/
public function get_configdata_encoded_attributes() {
return array();
return [];
}

/**
Expand All @@ -128,7 +128,7 @@ public function get_configdata_encoded_attributes() {
* @return array An empty array
*/
public static function define_decode_contents() {
return array();
return [];
}

/**
Expand All @@ -137,6 +137,6 @@ public static function define_decode_contents() {
* @return array An empty array
*/
public static function define_decode_rules() {
return array();
return [];
}
}
16 changes: 8 additions & 8 deletions block_completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}

/**
Expand All @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions classes/completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -736,7 +736,7 @@ protected function load_submissions() {
'gmavg' => QUIZ_GRADEAVERAGE,
],
],
);
];

$this->submissions = [];
foreach ($queries as $spec) {
Expand Down
66 changes: 33 additions & 33 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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]);

Expand All @@ -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) {
Expand All @@ -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.
Expand All @@ -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;
Expand All @@ -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';

Expand Down Expand Up @@ -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');
Expand All @@ -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'];
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion classes/table/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions css.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading