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
15 changes: 15 additions & 0 deletions classes/completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class completion_progress implements \renderable {
*/
const ORDERBY_TIME = 'orderbytime';

/**
* Sort activities by name.
*/
const ORDERBY_NAME = 'orderbyname';

/**
* The course.
* @var object
Expand Down Expand Up @@ -414,6 +419,16 @@ private function sorter_orderbytime($a, $b): int {
}
}

/**
* Used to compare two activity entries based on activityname.
*
* @param array $a
* @param array $b
* @return integer
*/
private function sorter_orderbyname($a, $b): int {
return $a->name <=> $b->name;
}

/**
* Loads activities with completion set in current course.
Expand Down
4 changes: 4 additions & 0 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ protected function specific_definition($mform) {
'block_completion_progress', $expectedbystring),
completion_progress::ORDERBY_COURSE => get_string('config_orderby_course_order',
'block_completion_progress'),
completion_progress::ORDERBY_NAME => get_string('config_orderby_name',
'block_completion_progress'),
completion_progress::ORDERBY_IDNUMBER => get_string('config_orderby_idnumber',
'block_completion_progress'),
);
$label = get_string('config_orderby', 'block_completion_progress');
$mform->addElement('select', 'config_orderby', $label, $options);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/block_completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
$string['config_orderby'] = 'Order bar by';
$string['config_orderby_course_order'] = 'Ordering in course';
$string['config_orderby_due_time'] = 'Time using "{$a}" date';
$string['config_orderby_name'] = 'Name of activity';
$string['config_orderby_idnumber'] = 'IDNumber of activity';
$string['config_percentage'] = 'Show percentage to students';
$string['config_scroll'] = 'Scroll';
$string['config_selectactivities'] = 'Select activities';
Expand Down