MDL-53453 cbe: False negative on MySQL due to random ordering

This commit is contained in:
Frederic Massart 2016-03-14 16:04:04 +08:00
parent 96c2b8477f
commit fd7e6bfd4a

View File

@ -4020,17 +4020,18 @@ class api {
} }
} }
$select = 'usercompetencyid = :usercompetencyid';
$params = array('usercompetencyid' => $usercompetency->get_id());
if ($plancompleted) { if ($plancompleted) {
$select = 'usercompetencyid = :usercompetencyid AND timecreated <= :timecompeleted'; $select .= ' AND timecreated <= :timecompleted';
$params = array('usercompetencyid' => $usercompetency->get_id(), 'timecompeleted' => $plan->get_timemodified()); $params['timecompleted'] = $plan->get_timemodified();
$orderby = $sort . ' ' . $order;
$evidences = evidence::get_records_select($select, $params, $orderby, '*', $skip, $limit);
} else {
$params = array('usercompetencyid' => $usercompetency->get_id());
$evidences = evidence::get_records($params, $sort, $order, $skip, $limit);
} }
return $evidences; $orderby = $sort . ' ' . $order;
$orderby .= !empty($orderby) ? ', id DESC' : 'id DESC'; // Prevent random ordering.
$evidence = evidence::get_records_select($select, $params, $orderby, '*', $skip, $limit);
return $evidence;
} }
/** /**