mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-59049 badges: allows users to view badges from deleted courses
This commit is contained in:
parent
27466d7548
commit
c09541fd28
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user