This commit is contained in:
Sara Arjona 2021-11-02 18:00:40 +01:00
commit 32e7e6fa37
2 changed files with 14 additions and 11 deletions

View File

@ -30,6 +30,7 @@ defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/badgeslib.php');
use context_course;
use context_system;
use stdClass;
use renderable;
@ -117,12 +118,12 @@ class issued_badge implements renderable {
$data = new stdClass();
$badge = new badge($this->badgeid);
if ($badge->type == BADGE_TYPE_COURSE && isset($badge->courseid)) {
$coursename = $DB->get_field('course', 'fullname', ['id' => $badge->courseid]);
$data->coursefullname = $coursename;
$context = \context_course::instance($badge->courseid);
$context = context_course::instance($badge->courseid);
$data->coursefullname = format_string($DB->get_field('course', 'fullname', ['id' => $badge->courseid]),
true, ['context' => $context]);
} else {
$data->sitefullname = $SITE->fullname;
$context = \context_system::instance();
$context = context_system::instance();
$data->sitefullname = format_string($SITE->fullname, true, ['context' => $context]);
}
// Field: Image.
@ -158,9 +159,9 @@ class issued_badge implements renderable {
$data->criteria = $output->print_badge_criteria($badge);
// Field: Issuer.
$data->issuedby = $badge->issuername;
$data->issuedby = format_string($badge->issuername, true, ['context' => $context]);
if (isset($badge->issuercontact) && !empty($badge->issuercontact)) {
$data->issuedbyemailobfuscated = obfuscate_mailto($badge->issuercontact, $badge->issuername);
$data->issuedbyemailobfuscated = obfuscate_mailto($badge->issuercontact, $data->issuedby);
}
// Fields: Other details, such as language or version.

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 set the following fields to these values:
| Name | Course Badge |
@ -197,7 +198,8 @@ 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 I should see "Course: Course 1"
@javascript
Scenario: Award badge on activity completion