MDL-70786 report_log: respect fullname setting.

This commit is contained in:
Luca Bösch
2021-05-04 14:19:17 +02:00
parent a11c2cb391
commit b74abdbea1
4 changed files with 37 additions and 15 deletions
+8 -1
View File
@@ -299,7 +299,14 @@ class report_log_renderable implements renderable {
*/
public function get_selected_user_fullname() {
$user = core_user::get_user($this->userid);
return fullname($user);
if (empty($this->course)) {
// We are in system context.
$context = context_system::instance();
} else {
// We are in course context.
$context = context_course::instance($this->course->id);
}
return fullname($user, has_capability('moodle/site:viewfullnames', $context));
}
/**
+2 -2
View File
@@ -130,7 +130,7 @@ class report_log_table_log extends table_sql {
return false;
}
$this->userfullnames[$userid] = fullname($user);
$this->userfullnames[$userid] = fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
return $this->userfullnames[$userid];
}
@@ -592,7 +592,7 @@ class report_log_table_log extends table_sql {
$users = $DB->get_records_sql("SELECT id," . get_all_user_name_fields(true) . " FROM {user} WHERE id " . $usql,
$uparams);
foreach ($users as $userid => $user) {
$this->userfullnames[$userid] = fullname($user);
$this->userfullnames[$userid] = fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
unset($userids[$userid]);
}
+9 -5
View File
@@ -9,12 +9,16 @@ Feature: In a report, admin can filter log data
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic |
| teacher1 | Teacher | One | teacher1@example.com | t1 | | fred | | |
| student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham |
And the following "course enrolments" exist:
| user | course | role |
| admin | C1 | editingteacher |
| student1 | C1 | student |
And the following config values are set as admin:
| fullnamedisplay | firstname |
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
And I log in as "admin"
Scenario: Filter log report for standard and legacy log reader
@@ -25,7 +29,7 @@ Feature: In a report, admin can filter log data
And I follow "Home"
And I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I click on "Log in as" "link"
And I press "Continue"
And I log out
@@ -44,7 +48,7 @@ Feature: In a report, admin can filter log data
Scenario: Filter log report for standard log reader
Given I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I click on "Log in as" "link"
And I press "Continue"
And I log out
@@ -66,7 +70,7 @@ Feature: In a report, admin can filter log data
And I follow "Home"
And I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I click on "Log in as" "link"
And I press "Continue"
And I log out
+18 -7
View File
@@ -9,13 +9,16 @@ Feature: User can view activity log.
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic |
| teacher1 | Teacher | One | teacher1@example.com | t1 | | fred | | |
| student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following config values are set as admin:
| fullnamedisplay | firstname |
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
@@ -37,10 +40,10 @@ Feature: User can view activity log.
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
When I follow "Today's logs"
And I should see "Assignment: Test assignment name"
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I follow "All logs"
Then I should see "Assignment: Test assignment name"
@@ -52,9 +55,17 @@ Feature: User can view activity log.
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
When I follow "Today's logs"
And I should see "No log reader enabled"
And I follow "Student 1"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I follow "All logs"
Then I should see "No log reader enabled"
Scenario: View Todays' log report for user through Course log report
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Reports > Logs" in current page administration
And I set the field with xpath "//select[@name='user']" to "Ann, Jill, Grainne, Beauchamp"
When I click on "Get these logs" "button"
Then I should see "Ann, Jill, Grainne, Beauchamp"