Permalink
Browse files

MDL-39790 Add badges block to the course page

  • Loading branch information...
1 parent f65261d commit 626c84bca91e6ceeaaef08691f06dea4fafad6c2 @ybozhko ybozhko committed May 28, 2013
Showing with 11 additions and 3 deletions.
  1. +11 −3 blocks/badges/block_badges.php
@@ -52,7 +52,7 @@ public function applicable_formats() {
return array(
'admin' => false,
'site-index' => true,
- 'course-view' => false,
+ 'course-view' => true,
'mod' => false,
'my' => true
);
@@ -88,8 +88,16 @@ public function get_content() {
if (empty($CFG->enablebadges)) {
$this->content->text .= get_string('badgesdisabled', 'badges');
- } else if ($badges = badges_get_user_badges($USER->id, null, 0, $this->config->numberofbadges)) {
- $output = $PAGE->get_renderer('core', 'badges');
+ return $this->content;
+ }
+
+ $courseid = $this->page->course->id;
+ if ($courseid == SITEID) {
+ $courseid = null;
+ }
+
+ if ($badges = badges_get_user_badges($USER->id, $courseid, 0, $this->config->numberofbadges)) {
+ $output = $this->page->get_renderer('core', 'badges');
$this->content->text = $output->print_badges_list($badges, $USER->id, true);
} else {
$this->content->text .= get_string('nothingtodisplay', 'block_badges');

0 comments on commit 626c84b

Please sign in to comment.