MDL-41659 badges: Display course/site names through format_string()
authorYuliya Bozhko <yuliya.bozhko@totaralms.com>
Fri, 20 Sep 2013 02:33:16 +0000 (14:33 +1200)
committerYuliya Bozhko <yuliya.bozhko@totaralms.com>
Tue, 1 Oct 2013 19:58:02 +0000 (08:58 +1300)
badges/criteria/award_criteria_courseset.php
badges/index.php
badges/newbadge.php
badges/renderer.php
badges/view.php

index 8144a38..a20e70b 100644 (file)
@@ -160,10 +160,11 @@ class award_criteria_courseset extends award_criteria {
         // In courseset, print out only the ones that were already selected.
         foreach ($this->params as $p) {
             if ($course = $DB->get_record('course', array('id' => $p['course']))) {
+                $coursecontext = context_course::instance($course->id);
                 $param = array(
                         'id' => $course->id,
                         'checked' => true,
-                        'name' => ucfirst($course->fullname),
+                        'name' => ucfirst(format_string($course->fullname, true, array('context' => $coursecontext))),
                         'error' => false
                 );
 
index a0d2f17..d476cfc 100644 (file)
@@ -82,10 +82,11 @@ if ($type == BADGE_TYPE_SITE) {
     navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)));
 } else {
     require_login($course);
+    $coursecontext = context_course::instance($course->id);
     $title = get_string('coursebadges', 'badges');
-    $PAGE->set_context(context_course::instance($course->id));
+    $PAGE->set_context($coursecontext);
     $PAGE->set_pagelayout('course');
-    $PAGE->set_heading($course->fullname . ': ' . $hdr);
+    $PAGE->set_heading(format_string($course->fullname, true, array('context' => $coursecontext)) . ': ' . $hdr);
     navigation_node::override_active_url(
         new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_COURSE, 'id' => $course->id))
     );
index 756ef91..d83ce59 100644 (file)
@@ -45,11 +45,13 @@ $title = get_string('create', 'badges');
 
 if (($type == BADGE_TYPE_COURSE) && ($course = $DB->get_record('course', array('id' => $courseid)))) {
     require_login($course);
-    $PAGE->set_context(context_course::instance($course->id));
+    $coursecontext = context_course::instance($course->id);
+    $PAGE->set_context($coursecontext);
     $PAGE->set_pagelayout('course');
     $PAGE->set_url('/badges/newbadge.php', array('type' => $type, 'id' => $course->id));
-    $PAGE->set_heading($course->fullname . ": " . $title);
-    $PAGE->set_title($course->fullname . ": " . $title);
+    $heading = format_string($course->fullname, true, array('context' => $coursecontext)) . ": " . $title;
+    $PAGE->set_heading($heading);
+    $PAGE->set_title($heading);
 } else {
     $PAGE->set_context(context_system::instance());
     $PAGE->set_pagelayout('admin');
index de4894e..7946f50 100644 (file)
@@ -494,8 +494,8 @@ class core_badges_renderer extends plugin_renderer_base {
 
         // Local badges.
         $localhtml = html_writer::start_tag('fieldset', array('id' => 'issued-badge-table', 'class' => 'generalbox'));
-        $localhtml .= html_writer::tag('legend',
-                    $this->output->heading_with_help(get_string('localbadges', 'badges', $SITE->fullname), 'localbadgesh', 'badges'));
+        $heading = get_string('localbadges', 'badges', format_string($SITE->fullname, true, array('context' => context_system::instance())));
+        $localhtml .= html_writer::tag('legend', $this->output->heading_with_help($heading, 'localbadgesh', 'badges'));
         if ($badges->badges) {
             $table = new html_table();
             $table->attributes['class'] = 'statustable';
index 33f2b91..d623c81 100644 (file)
@@ -68,7 +68,8 @@ if ($type == BADGE_TYPE_SITE) {
     $PAGE->set_heading($title);
 } else {
     require_login($course);
-    $title = $course->fullname . ': ' . get_string('coursebadges', 'badges');
+    $coursename = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
+    $title = $coursename . ': ' . get_string('coursebadges', 'badges');
     $PAGE->set_context(context_course::instance($course->id));
     $PAGE->set_pagelayout('course');
     $PAGE->set_heading($title);