MDL-63387 course: use renamed role names, update Behat tests.

Specify that we want both role names (renamed course role plus
original).
This commit is contained in:
Paul Holden
2020-09-01 12:05:20 +01:00
parent 0cfa744fd9
commit ad7d46ed2e
5 changed files with 22 additions and 8 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ class award_criteria_manual extends award_criteria {
$rec = $DB->get_record('role', array('id' => $rid));
if ($rec) {
return role_get_name($rec, $PAGE->context, ROLENAME_ALIAS);
return role_get_name($rec, $PAGE->context, ROLENAME_BOTH);
} else {
return null;
}
+1 -1
View File
@@ -88,7 +88,7 @@ if ($switchrole > 0 && has_capability('moodle/role:switchroles', $context)) {
$roles[0] = get_string('switchrolereturn');
$assumedrole = $USER->access['rsw'][$context->path];
}
$availableroles = get_switchable_roles($context);
$availableroles = get_switchable_roles($context, ROLENAME_BOTH);
if (is_array($availableroles)) {
foreach ($availableroles as $key => $role) {
if ($assumedrole == (int)$key) {
+9 -3
View File
@@ -32,9 +32,15 @@ Feature: Rename roles within a course
And I navigate to course participants
And I set the field "type" in the "Filter 1" "fieldset" to "Roles"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I should see "Tutor" in the ".form-autocomplete-suggestions" "css_element"
And I should see "Learner" in the ".form-autocomplete-suggestions" "css_element"
And I should not see "Student" in the ".form-autocomplete-suggestions" "css_element"
And I should see "Tutor (Non-editing teacher)" in the ".form-autocomplete-suggestions" "css_element"
And I should see "Learner (Student)" in the ".form-autocomplete-suggestions" "css_element"
And I click on "Student 1's role assignments" "link"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Student 1" "table_row"
And "Tutor (Non-editing teacher)" "autocomplete_suggestions" should exist
And I click on "Cancel" "link"
And I press "Enrol users"
And the "Assign role" select box should contain "Learner (Student)"
And I click on "Cancel" "button" in the "Enrol users" "dialogue"
And I am on "Course 1" course homepage
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
+10 -2
View File
@@ -26,9 +26,17 @@ Feature: Rename roles in a course
| Your word for 'Teacher' | Lecturer |
| Your word for 'Student' | Learner |
And I press "Save and display"
And I navigate to "Users > Enrolled users" in current page administration
Then I should see "Lecturer" in the "Teacher 1" "table_row"
And I navigate to course participants
Then I should see "Lecturer (Teacher)" in the "Teacher 1" "table_row"
And I should see "Learner (Student)" in the "Student 1" "table_row"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I navigate to course participants
And I should see "Lecturer" in the "Teacher 1" "table_row"
And I should see "Learner" in the "Student 1" "table_row"
And I should not see "Lecturer (Teacher)" in the "Teacher 1" "table_row"
And I should not see "Learner (Student)" in the "Student 1" "table_row"
Scenario: Ability to rename roles can be prevented
Given I log in as "admin"
+1 -1
View File
@@ -60,7 +60,7 @@ $preview = '';
$error = '';
/// Get applicable roles - used in menus etc later on
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_BOTH, true);
/// Create the form
$editform = new autogroup_form(null, array('roles' => $rolenames));