MDL-64009 badges: Removed additional badge information when null.
authorAdrian Greeve <abgreeve@gmail.com>
Thu, 15 Nov 2018 06:04:51 +0000 (14:04 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Thu, 15 Nov 2018 06:04:51 +0000 (14:04 +0800)
On the badge display page if the badge does not have an endorsement,
related badges, or competency allignments, then these sections are
not shown.

badges/renderer.php

index 5810e57..359203e 100644 (file)
@@ -405,28 +405,27 @@ class core_badges_renderer extends plugin_renderer_base {
 
         $dl[get_string('evidence', 'badges')] = get_string('completioninfo', 'badges') . html_writer::alist($items, array(), 'ul');
         $output .= $this->definition_list($dl);
-        $output .= self::print_badge_endorsement($badge);
+        $endorsement = $badge->get_endorsement();
+        if (!empty($endorsement)) {
+            $output .= self::print_badge_endorsement($badge);
+        }
         $relatedbadges = $badge->get_related_badges();
-        $output .= $this->heading(get_string('relatedbages', 'badges'), 3);
         if (!empty($relatedbadges)) {
+            $output .= $this->heading(get_string('relatedbages', 'badges'), 3);
             $items = array();
             foreach ($relatedbadges as $related) {
                 $items[] = $related->name;
             }
             $output .= html_writer::alist($items, array(), 'ul');
-        } else {
-            $output .= get_string('norelated', 'badges');
         }
-        $output .= $this->heading(get_string('alignment', 'badges'), 3);
         $competencies = $badge->get_alignment();
         if (!empty($competencies)) {
+            $output .= $this->heading(get_string('alignment', 'badges'), 3);
             $items = array();
             foreach ($competencies as $competency) {
                 $items[] = html_writer::link($competency->targeturl, $competency->targetname, array('target' => '_blank'));
             }
             $output .= html_writer::alist($items, array(), 'ul');
-        } else {
-            $output .= get_string('noalignment', 'badges');
         }
         $output .= html_writer::end_tag('div');