Skip to content

Commit

Permalink
MDL-59049 badges: allows users to view badges from deleted courses
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Aug 18, 2017
1 parent 27466d7 commit c09541f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion badges/criteria/award_criteria_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public function __construct($record) {
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;
}

Expand Down
7 changes: 6 additions & 1 deletion badges/criteria/award_criteria_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ public function __construct($record) {
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;
}

Expand Down

0 comments on commit c09541f

Please sign in to comment.