mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-55043 core_competency: Sort by id to ensure we get expected result.
This commit is contained in:
parent
2648dddd2a
commit
56c5c9a08a
@ -4152,7 +4152,7 @@ class api {
|
||||
* @param int $limit Number of records to return.
|
||||
* @return \core_competency\evidence[]
|
||||
*/
|
||||
public static function list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated, id',
|
||||
public static function list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated',
|
||||
$order = 'DESC', $skip = 0, $limit = 0) {
|
||||
static::require_enabled();
|
||||
|
||||
|
@ -311,11 +311,9 @@ class evidence extends persistent {
|
||||
);
|
||||
|
||||
if (!empty($sort)) {
|
||||
$sortcolumns = explode(',', $sort);
|
||||
array_walk($sortcolumns, function(&$sortcolumn, $key, $order) {
|
||||
$sortcolumn = trim($sortcolumn) . ' ' . $order;
|
||||
}, $order);
|
||||
$sort = ' ORDER BY e.' . implode(', e.', $sortcolumns);
|
||||
$sort = ' ORDER BY e.' . $sort . ' ' . $order . ', e.id ASC';
|
||||
} else {
|
||||
$sort = ' ORDER BY e.id ASC';
|
||||
}
|
||||
|
||||
$sql = 'SELECT e.*
|
||||
|
@ -2615,9 +2615,9 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$evidence2 = api::add_evidence($u1->id, $c->get_id(), $cmcontext->id, \core_competency\evidence::ACTION_LOG,
|
||||
'invaliddata', 'error');
|
||||
|
||||
$result = api::list_evidence_in_course($u1->id, $course->id, $c->get_id());
|
||||
$this->assertEquals($result[0]->get_id(), $evidence2->get_id());
|
||||
$this->assertEquals($result[1]->get_id(), $evidence1->get_id());
|
||||
$result = api::list_evidence_in_course($u1->id, $course->id, $c->get_id(), 'timecreated', 'ASC');
|
||||
$this->assertEquals($evidence1->get_id(), $result[0]->get_id());
|
||||
$this->assertEquals($evidence2->get_id(), $result[1]->get_id());
|
||||
}
|
||||
|
||||
public function test_list_course_modules_using_competency() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user