Merge branch 'MDL-59049-master' of https://github.com/snake/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2017-08-21 23:09:09 +02:00
commit 6b1e790231
2 changed files with 12 additions and 2 deletions

View file

@ -47,8 +47,13 @@ class award_criteria_activity extends award_criteria {
parent::__construct($record);
$this->course = $DB->get_record_sql('SELECT c.id, c.enablecompletion, c.cacherev, c.startdate
FROM {badge} b INNER JOIN {course} c ON b.courseid = c.id
FROM {badge} b LEFT JOIN {course} c ON b.courseid = c.id
WHERE b.id = :badgeid ', array('badgeid' => $this->badgeid), MUST_EXIST);
// If the course doesn't exist but we're sure the badge does (thanks to the LEFT JOIN), then use the site as the course.
if (empty($this->course->id)) {
$this->course = get_course(SITEID);
}
$this->courseid = $this->course->id;
}

View file

@ -49,8 +49,13 @@ class award_criteria_course extends award_criteria {
parent::__construct($record);
$this->course = $DB->get_record_sql('SELECT c.id, c.enablecompletion, c.cacherev, c.startdate
FROM {badge} b INNER JOIN {course} c ON b.courseid = c.id
FROM {badge} b LEFT JOIN {course} c ON b.courseid = c.id
WHERE b.id = :badgeid ', array('badgeid' => $this->badgeid), MUST_EXIST);
// If the course doesn't exist but we're sure the badge does (thanks to the LEFT JOIN), then use the site as the course.
if (empty($this->course->id)) {
$this->course = get_course(SITEID);
}
$this->courseid = $this->course->id;
}