From a6e2d950e7179ae7af5d5e90dfe51142b56bf5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Sat, 6 Feb 2021 12:47:25 +0100 Subject: [PATCH] MDL-70786 report_competency: respect fullname setting. --- .../classes/output/user_course_navigation.php | 11 +++++------ report/competency/index.php | 2 +- .../tests/behat/breakdown_by_activity.feature | 13 +++++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/report/competency/classes/output/user_course_navigation.php b/report/competency/classes/output/user_course_navigation.php index 57735788ede..d67e9e0a1df 100644 --- a/report/competency/classes/output/user_course_navigation.php +++ b/report/competency/classes/output/user_course_navigation.php @@ -110,12 +110,11 @@ class user_course_navigation implements renderable, templatable { $data->users = array(); foreach ($users as $user) { - $exporter = new user_summary_exporter($user); - $user = $exporter->export($output); - if ($user->id == $this->userid) { - $user->selected = true; - } - $data->users[] = $user; + $data->users[] = (object)[ + 'id' => $user->id, + 'fullname' => fullname($user, has_capability('moodle/site:viewfullnames', $context)), + 'selected' => $user->id == $this->userid + ]; } $data->hasusers = true; diff --git a/report/competency/index.php b/report/competency/index.php index ccf0eb829ee..8ddf79b9eb2 100644 --- a/report/competency/index.php +++ b/report/competency/index.php @@ -81,7 +81,7 @@ if ($currentuser > 0) { $user = core_user::get_user($currentuser); $usercontext = context_user::instance($currentuser); $userheading = array( - 'heading' => fullname($user), + 'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $context)), 'user' => $user, 'usercontext' => $usercontext ); diff --git a/report/competency/tests/behat/breakdown_by_activity.feature b/report/competency/tests/behat/breakdown_by_activity.feature index db8a055122b..833de9ac71e 100644 --- a/report/competency/tests/behat/breakdown_by_activity.feature +++ b/report/competency/tests/behat/breakdown_by_activity.feature @@ -16,14 +16,19 @@ Feature: See the competencies for an activity | shortname | fullname | | C1 | Course 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 | + | student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham | + | student2 | Niamh | Cholmondely | student2@example.com | s2 | Jane | Nina | Nee | Chumlee | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | + | student2 | C1 | student | And the following "activities" exist: | activity | name | intro | course | idnumber | | page | PageName1 | PageDesc1 | C1 | PAGE1 | + And the following config values are set as admin: + | fullnamedisplay | firstname | + | alternativefullnameformat | middlename, alternatename, firstname, lastname | And I log in as "admin" And I am on site homepage And I follow "Course 1" @@ -49,6 +54,10 @@ Feature: See the competencies for an activity And I set the field "Filter competencies by resource or activity" to "PageName1" Then I should see "Test-Comp1" And I should not see "Test-Comp2" + And I should see "Ann, Jill, Grainne, Beauchamp" + And I should see "Ann, Jill, Grainne, Beauchamp" in the ".form-autocomplete-selection" "css_element" + And I open the autocomplete suggestions list + And I should see "Jane, Nina, Niamh, Cholmondely" in the ".form-autocomplete-suggestions" "css_element" And I click on "Not rated" "link" And I click on "Rate" "button" And I set the field "Rating" to "A"