MDL-72857 badges: filter site/course name when showing issued badge.

This commit is contained in:
Paul Holden 2021-10-19 19:50:45 +01:00
parent ee1c3d9837
commit 40451d3a90
2 changed files with 11 additions and 6 deletions

View file

@ -380,7 +380,9 @@ class core_badges_renderer extends plugin_renderer_base {
$output .= $this->output->heading(get_string('issuerdetails', 'badges'), 3);
$dl = array();
$dl[get_string('issuername', 'badges')] = $badge->issuername;
$dl[get_string('issuername', 'badges')] = format_string($badge->issuername, true,
['context' => context_system::instance()]);
if (isset($badge->issuercontact) && !empty($badge->issuercontact)) {
$dl[get_string('contact', 'badges')] = obfuscate_mailto($badge->issuercontact);
}
@ -413,7 +415,7 @@ class core_badges_renderer extends plugin_renderer_base {
if ($badge->type == BADGE_TYPE_COURSE && isset($badge->courseid)) {
$coursename = $DB->get_field('course', 'fullname', array('id' => $badge->courseid));
$dl[get_string('course')] = $coursename;
$dl[get_string('course')] = format_string($coursename, true, ['context' => context_course::instance($badge->courseid)]);
}
$dl[get_string('bcriteria', 'badges')] = self::print_badge_criteria($badge);
$output .= $this->definition_list($dl);

View file

@ -163,16 +163,17 @@ Feature: Award badges
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
| <span class="multilang" lang="en">Course 1</span><span class="multilang" lang="de">Kurs 1</span> | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I am on the "C1" "Course" page logged in as "teacher1"
And I navigate to "Badges > Add a new badge" in current page administration
And I follow "Add a new badge"
And I set the following fields to these values:
@ -197,7 +198,9 @@ Feature: Award badges
And I log in as "student1"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
And I should see "Course Badge"
And I click on "Course Badge" "link"
And "Course 1" "text" should appear after "Badge details" "text"
And "Kurs 1" "text" should not exist
@javascript
Scenario: Award badge on activity completion