mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-51917 course completion: order activities in reports
Thanks to Nick Phillips for initial patch
This commit is contained in:
parent
4c6063bff9
commit
fe81ef397c
1 changed files with 15 additions and 0 deletions
|
@ -423,6 +423,21 @@ class completion_info {
|
||||||
// Load criteria from database
|
// Load criteria from database
|
||||||
$records = (array)$DB->get_records('course_completion_criteria', $params);
|
$records = (array)$DB->get_records('course_completion_criteria', $params);
|
||||||
|
|
||||||
|
// Order records so activities are in the same order as they appear on the course view page.
|
||||||
|
if ($records) {
|
||||||
|
$activitiesorder = array_keys(get_fast_modinfo($this->course)->get_cms());
|
||||||
|
usort($records, function ($a, $b) use ($activitiesorder) {
|
||||||
|
$aidx = ($a->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ?
|
||||||
|
array_search($a->moduleinstance, $activitiesorder) : false;
|
||||||
|
$bidx = ($b->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ?
|
||||||
|
array_search($b->moduleinstance, $activitiesorder) : false;
|
||||||
|
if ($aidx === false || $bidx === false || $aidx == $bidx) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($aidx < $bidx) ? -1 : 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Build array of criteria objects
|
// Build array of criteria objects
|
||||||
$this->criteria = array();
|
$this->criteria = array();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue