MDL-87251 enrol_self: Improve enrolment title display
This commit is contained in:
@@ -85,7 +85,7 @@ final class participants_test extends core_reportbuilder_testcase {
|
||||
|
||||
$this->assertEquals([
|
||||
["<a href=\"{$coursetwourl}\">{$coursetwo->fullname}</a>",
|
||||
"<a href=\"{$useroneurl}\">" . fullname($userone) . "</a>", 'Self enrolment (Student)'],
|
||||
"<a href=\"{$useroneurl}\">" . fullname($userone) . "</a>", 'Self enrolment as \'Student\''],
|
||||
["<a href=\"{$courseoneurl}\">{$courseone->fullname}</a>",
|
||||
"<a href=\"{$usertwourl}\">" . fullname($usertwo) . "</a>", 'Manual enrolments'],
|
||||
["<a href=\"{$courseoneurl}\">{$courseone->fullname}</a>",
|
||||
|
||||
@@ -33,6 +33,7 @@ $string['defaultrole'] = 'Default role assignment';
|
||||
$string['defaultrole_desc'] = 'Select role which should be assigned to users during self enrolment';
|
||||
$string['deleteselectedusers'] = 'Delete selected user enrolments';
|
||||
$string['editselectedusers'] = 'Edit selected user enrolments';
|
||||
$string['enroledas'] = '{$a->enrol} as \'{$a->role}\'';
|
||||
$string['enrolenddate'] = 'End date';
|
||||
$string['enrolenddate_help'] = 'If enabled, users can enrol themselves until this date only.';
|
||||
$string['enrolenddaterror'] = 'Enrolment end date cannot be earlier than start date';
|
||||
|
||||
+13
-10
@@ -83,17 +83,20 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
public function get_instance_name($instance) {
|
||||
global $DB;
|
||||
|
||||
if (empty($instance->name)) {
|
||||
if (!empty($instance->roleid) and $role = $DB->get_record('role', array('id'=>$instance->roleid))) {
|
||||
$role = ' (' . role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING)) . ')';
|
||||
} else {
|
||||
$role = '';
|
||||
}
|
||||
$enrol = $this->get_name();
|
||||
return get_string('pluginname', 'enrol_'.$enrol) . $role;
|
||||
} else {
|
||||
return format_string($instance->name);
|
||||
if (!empty($instance->name)) {
|
||||
return format_string($instance->name, true, ['context' => context_course::instance($instance->courseid)]);
|
||||
}
|
||||
|
||||
$enrolname = get_string('pluginname', 'enrol_' . $this->get_name());
|
||||
if (!empty($instance->roleid)) {
|
||||
$role = $DB->get_record('role', ['id' => $instance->roleid]);
|
||||
if ($role) {
|
||||
$rolename = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING));
|
||||
return get_string('enroledas', 'enrol_self', ['enrol' => $enrolname, 'role' => $rolename]);
|
||||
}
|
||||
}
|
||||
|
||||
return $enrolname;
|
||||
}
|
||||
|
||||
public function roles_protected() {
|
||||
|
||||
@@ -162,7 +162,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe
|
||||
Scenario: Self-enrolment enabled with simultaneous guest access
|
||||
Given I log in as "teacher1"
|
||||
And I am on the "Course 1" "enrolment methods" page
|
||||
And I click on "Enable" "link" in the "Self enrolment (Student)" "table_row"
|
||||
And I click on "Enable" "link" in the "Self enrolment as 'Student'" "table_row"
|
||||
And I click on "Edit" "link" in the "Guest access" "table_row"
|
||||
And I set the following fields to these values:
|
||||
| Allow guest access | Yes |
|
||||
|
||||
Reference in New Issue
Block a user