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" diff --git a/report/completion/index.php b/report/completion/index.php index a2355118056..73380d7e011 100644 --- a/report/completion/index.php +++ b/report/completion/index.php @@ -546,7 +546,7 @@ foreach ($progress as $user) { if ($csv) { $row = array(); $row[] = $user->id; - $row[] = fullname($user); + $row[] = fullname($user, has_capability('moodle/site:viewfullnames', $context)); foreach ($extrafields as $field) { $row[] = $user->{$field}; } @@ -559,7 +559,8 @@ foreach ($progress as $user) { $userurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id)); } - print ''.fullname($user).''; + print '' . + fullname($user, has_capability('moodle/site:viewfullnames', $context)) . ''; foreach ($extrafields as $field) { echo ''.s($user->{$field}).''; } diff --git a/report/completion/tests/behat/completion_report.feature b/report/completion/tests/behat/completion_report.feature new file mode 100644 index 00000000000..0f2af7b930a --- /dev/null +++ b/report/completion/tests/behat/completion_report.feature @@ -0,0 +1,37 @@ +@report @report_completion +Feature: See the completion for items in a course + In order see completion data + As a teacher + I need to view completion report + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic | + | teacher1 | Teacher | 1 | teacher1@example.com | t1 | | fred | | | + | student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham | + And the following "courses" exist: + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "activities" exist: + | activity | name | intro | course | idnumber | completion | completionview | + | page | PageName1 | PageDesc1 | C1 | PAGE1 | 1 | 1 | + And the following config values are set as admin: + | fullnamedisplay | firstname | + | alternativefullnameformat | middlename, alternatename, firstname, lastname | + + @javascript + Scenario: Go to the completion report + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Course completion" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Page - PageName1 | 1 | + And I press "Save changes" + And I am on "Course 1" course homepage + When I navigate to "Reports > Course completion" in current page administration + Then I should see "Ann, Jill, Grainne, Beauchamp" diff --git a/report/log/classes/renderable.php b/report/log/classes/renderable.php index 10b580ffff7..597ae1f226f 100644 --- a/report/log/classes/renderable.php +++ b/report/log/classes/renderable.php @@ -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)); } /** diff --git a/report/log/classes/table_log.php b/report/log/classes/table_log.php index 845fac2e696..a02a715ede2 100644 --- a/report/log/classes/table_log.php +++ b/report/log/classes/table_log.php @@ -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]); } diff --git a/report/log/tests/behat/filter_log.feature b/report/log/tests/behat/filter_log.feature index 9f2174d652d..a6619e97fa5 100644 --- a/report/log/tests/behat/filter_log.feature +++ b/report/log/tests/behat/filter_log.feature @@ -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 diff --git a/report/log/tests/behat/user_log.feature b/report/log/tests/behat/user_log.feature index b8726726f82..d4106aee7be 100644 --- a/report/log/tests/behat/user_log.feature +++ b/report/log/tests/behat/user_log.feature @@ -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" diff --git a/report/loglive/classes/table_log.php b/report/loglive/classes/table_log.php index 798a801467a..97103f989a1 100644 --- a/report/loglive/classes/table_log.php +++ b/report/loglive/classes/table_log.php @@ -377,7 +377,7 @@ class report_loglive_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())); } } diff --git a/report/loglive/tests/behat/loglive_report.feature b/report/loglive/tests/behat/loglive_report.feature index f0699e6d871..b6ce06e2503 100644 --- a/report/loglive/tests/behat/loglive_report.feature +++ b/report/loglive/tests/behat/loglive_report.feature @@ -8,6 +8,15 @@ Feature: In a report, admin can see loglive data Given the following "courses" exist: | fullname | shortname | category | groupmode | | Course 1 | C1 | 0 | 1 | + And the following "users" exist: + | username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic | + | student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham | + And the following "course enrolments" exist: + | user | course | role | + | 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" And I navigate to "Plugins > Logging > Manage log stores" in site administration And I click on "Enable" "link" in the "Legacy log" "table_row" @@ -72,3 +81,24 @@ Feature: In a report, admin can see loglive data And I wait "8" seconds And I should see "Test name2" And I log out + + @javascript + Scenario: Check course loglive report entries for a user + Given I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Test name" + And I log out + And I log in as "admin" + And I am on "Course 1" course homepage + And I navigate to "Reports > Live logs" in site administration + When I set the field "reader" to "Standard log" + Then I should see "Course module viewed" + And I should see "Test name" + And I should see "Ann, Jill, Grainne, Beauchamp" + And I set the field "reader" to "Legacy log" + And I wait to be redirected + And I should see "course_add mod" + And I wait "8" seconds + And I should see "Test name" + And I log out diff --git a/report/progress/index.php b/report/progress/index.php index 596692cb7a5..87ee38e13ca 100644 --- a/report/progress/index.php +++ b/report/progress/index.php @@ -360,13 +360,14 @@ if ($csv) { foreach($progress as $user) { // User name if ($csv) { - print csv_quote(fullname($user)); + print csv_quote(fullname($user, has_capability('moodle/site:viewfullnames', $context))); foreach ($extrafields as $field) { echo $sep . csv_quote($user->{$field}); } } else { - print ''.fullname($user).''; + print '' . + fullname($user, has_capability('moodle/site:viewfullnames', $context)) . ''; foreach ($extrafields as $field) { echo '' . s($user->{$field}) . ''; } @@ -414,7 +415,7 @@ foreach($progress as $user) { $a=new StdClass; $a->state=$describe; $a->date=$date; - $a->user=fullname($user); + $a->user = fullname($user, has_capability('moodle/site:viewfullnames', $context)); $a->activity = $formattedactivities[$activity->id]->displayname; $fulldescribe=get_string('progress-title','completion',$a); diff --git a/report/progress/tests/behat/activity_completion_report.feature b/report/progress/tests/behat/activity_completion_report.feature index 4885029a17a..4a08d45c845 100644 --- a/report/progress/tests/behat/activity_completion_report.feature +++ b/report/progress/tests/behat/activity_completion_report.feature @@ -14,13 +14,16 @@ Feature: Teacher can view and override users' activity completion data via the p | assign | my assignment 2 | A2 desc | C1 | assign2 | 0 | 2 | 1 | | 0 | 0 | | assign | my assignment 3 | A3 desc | C1 | assign3 | 0 | 2 | 1 | 1 | 1 | 0 | And the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | One | teacher1@example.com | - | student1 | Student | One | 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 | # Course comprising one activity with auto completion (student must view it) and one with manual completion. # This confirms that after being completed by the student and overridden by the teacher, that both activities can still be @@ -42,21 +45,21 @@ Feature: Teacher can view and override users' activity completion data via the p When I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration - And "Student One, my assignment: Completed" "icon" should exist in the "Student One" "table_row" - And "Student One, my assignment 2: Completed" "icon" should exist in the "Student One" "table_row" - And I click on "my assignment" "link" in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And I click on "my assignment" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I click on "Save changes" "button" - And "Student One, my assignment: Not completed (set by Teacher One)" "icon" should exist in the "Student One" "table_row" - And I click on "my assignment 2" "link" in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment: Not completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And I click on "my assignment 2" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I click on "Save changes" "button" - And "Student One, my assignment 2: Not completed (set by Teacher One)" "icon" should exist in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Not completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I log out # Student can now complete the activities again, via normal means. Then I log in as "student1" And I am on "Course 1" course homepage - And "Not completed: my assignment (set by Teacher One). Select to mark as complete." "icon" should exist in the "my assignment" "list_item" - And "Not completed: my assignment 2 (set by Teacher One)" "icon" should exist in the "my assignment 2" "list_item" - And I click on "Not completed: my assignment (set by Teacher One). Select to mark as complete." "icon" + And "Not completed: my assignment (set by Teacher). Select to mark as complete." "icon" should exist in the "my assignment" "list_item" + And "Not completed: my assignment 2 (set by Teacher)" "icon" should exist in the "my assignment 2" "list_item" + And I click on "Not completed: my assignment (set by Teacher). Select to mark as complete." "icon" And "Completed: my assignment. Select to mark as not complete." "icon" should exist in the "my assignment" "list_item" And I click on "my assignment 2" "link" And I am on "Course 1" course homepage @@ -66,8 +69,8 @@ Feature: Teacher can view and override users' activity completion data via the p When I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration - And "Student One, my assignment: Completed" "icon" should exist in the "Student One" "table_row" - And "Student One, my assignment 2: Completed" "icon" should exist in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" # Course comprising one activity with auto completion (student must view it and receive a grade) and one with manual completion. # This confirms that after being overridden to complete by the teacher, that the completion status for activities with automatic @@ -78,19 +81,19 @@ Feature: Teacher can view and override users' activity completion data via the p When I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration - And "Student One, my assignment: Not completed" "icon" should exist in the "Student One" "table_row" - And "Student One, my assignment 3: Not completed" "icon" should exist in the "Student One" "table_row" - And I click on "my assignment" "link" in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment: Not completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment 3: Not completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And I click on "my assignment" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I click on "Save changes" "button" - And "Student One, my assignment: Completed (set by Teacher One)" "icon" should exist in the "Student One" "table_row" - And I click on "my assignment 3" "link" in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" + And I click on "my assignment 3" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I click on "Save changes" "button" - And "Student One, my assignment 3: Completed (set by Teacher One)" "icon" should exist in the "Student One" "table_row" + And "Ann, Jill, Grainne, Beauchamp, my assignment 3: Completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row" And I log out # Then as a student, confirm that automatic completion checks are no longer triggered (such as after an assign submission). Then I log in as "student1" And I am on "Course 1" course homepage - And "Completed: my assignment 3 (set by Teacher One)" "icon" should exist in the "my assignment 3" "list_item" + And "Completed: my assignment 3 (set by Teacher)" "icon" should exist in the "my assignment 3" "list_item" And I click on "my assignment 3" "link" And I press "Add submission" And I set the following fields to these values: @@ -98,10 +101,10 @@ Feature: Teacher can view and override users' activity completion data via the p And I press "Save changes" And I should see "Submitted for grading" And I am on "Course 1" course homepage - And "Completed: my assignment 3 (set by Teacher One)" "icon" should exist in the "my assignment 3" "list_item" + And "Completed: my assignment 3 (set by Teacher)" "icon" should exist in the "my assignment 3" "list_item" # And Confirm that manual completion changes are still allowed. And I am on "Course 1" course homepage - And "Completed: my assignment (set by Teacher One). Select to mark as not complete." "icon" should exist in the "my assignment" "list_item" - And I click on "Completed: my assignment (set by Teacher One). Select to mark as not complete." "icon" + And "Completed: my assignment (set by Teacher). Select to mark as not complete." "icon" should exist in the "my assignment" "list_item" + And I click on "Completed: my assignment (set by Teacher). Select to mark as not complete." "icon" And "Not completed: my assignment. Select to mark as complete." "icon" should exist in the "my assignment" "list_item" And I log out