MDL-64851 badge: reviewing badges of invisible courses

This commit is contained in:
Sara Cenni 2019-04-12 09:50:33 +02:00
parent dafcc3cf7b
commit d78d97de8c

View File

@ -53,14 +53,15 @@ class badges_cron_task extends scheduled_task {
if (empty($CFG->badges_allowcoursebadges)) { if (empty($CFG->badges_allowcoursebadges)) {
$coursesql = ''; $coursesql = '';
} else { } else {
$coursesql = ' OR EXISTS (SELECT id FROM {course} WHERE visible = :visible AND startdate < :current) '; $coursesql = ' OR EXISTS (SELECT c.id FROM {course} c WHERE c.visible = :visible AND c.startdate < :current'
. ' AND c.id = b.courseid) ';
$courseparams = array('visible' => true, 'current' => time()); $courseparams = array('visible' => true, 'current' => time());
} }
$sql = 'SELECT id $sql = 'SELECT b.id
FROM {badge} FROM {badge} b
WHERE (status = :active OR status = :activelocked) WHERE (b.status = :active OR b.status = :activelocked)
AND (type = :site ' . $coursesql . ')'; AND (b.type = :site ' . $coursesql . ')';
$badgeparams = [ $badgeparams = [
'active' => BADGE_STATUS_ACTIVE, 'active' => BADGE_STATUS_ACTIVE,
'activelocked' => BADGE_STATUS_ACTIVE_LOCKED, 'activelocked' => BADGE_STATUS_ACTIVE_LOCKED,