MDL-51110 badges: prevent duplicate award of badges

Previously duplicate users could be returned when they had
done duplicate badge criteria - this would lead to a duplicate
constraint being hit as they were attempted to be awarded twice.
This commit is contained in:
Dan Poltawski
2015-08-13 13:28:22 +01:00
parent 7da2ed7a24
commit 0571f136e6
+1 -1
View File
@@ -463,7 +463,7 @@ class badge {
$wheresql = ' WHERE u.id ' . $earnedsql;
}
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->get_context(), 'moodle/badges:earnbadge', 0, true);
$sql = "SELECT u.id
$sql = "SELECT DISTINCT u.id
FROM {user} u
{$extrajoin}
JOIN ({$enrolledsql}) je ON je.id = u.id " . $wheresql . $extrawhere;