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:12:52 +01:00
parent dda862abb5
commit 5f92c736e3

View File

@ -472,7 +472,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;