Skip to content

Commit

Permalink
Merge branch 'MDL-70786-master' of git://github.com/lucaboesch/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed May 6, 2021
2 parents f23236a + b8a0cc9 commit 266bcab
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 53 deletions.
11 changes: 5 additions & 6 deletions report/competency/classes/output/user_course_navigation.php
Expand Up @@ -110,12 +110,11 @@ public function export_for_template(renderer_base $output) {

$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;

Expand Down
2 changes: 1 addition & 1 deletion report/competency/index.php
Expand Up @@ -88,7 +88,7 @@
$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
);
Expand Down
13 changes: 11 additions & 2 deletions report/competency/tests/behat/breakdown_by_activity.feature
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions report/completion/index.php
Expand Up @@ -554,7 +554,7 @@
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};
}
Expand All @@ -567,7 +567,8 @@
$userurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
}

print '<th scope="row"><a href="'.$userurl->out().'">'.fullname($user).'</a></th>';
print '<th scope="row"><a href="' . $userurl->out() . '">' .
fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</a></th>';
foreach ($extrafields as $field) {
echo '<td>'.s($user->{$field}).'</td>';
}
Expand Down
37 changes: 37 additions & 0 deletions 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"
9 changes: 8 additions & 1 deletion report/log/classes/renderable.php
Expand Up @@ -299,7 +299,14 @@ public function get_actions() {
*/
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));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions report/log/classes/table_log.php
Expand Up @@ -132,7 +132,7 @@ protected function get_user_fullname($userid) {
return false;
}

$this->userfullnames[$userid] = fullname($user);
$this->userfullnames[$userid] = fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
return $this->userfullnames[$userid];
}

Expand Down Expand Up @@ -596,7 +596,7 @@ protected function update_users_used() {
" 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]);
}

Expand Down
14 changes: 9 additions & 5 deletions report/log/tests/behat/filter_log.feature
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
25 changes: 18 additions & 7 deletions report/log/tests/behat/user_log.feature
Expand Up @@ -9,9 +9,9 @@ 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 |
Expand All @@ -25,6 +25,9 @@ Feature: User can view activity log.
| section | 1 |
| assignsubmission_onlinetext_enabled | 1 |
| assignsubmission_file_enabled | 0 |
And the following config values are set as admin:
| fullnamedisplay | firstname |
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
Expand All @@ -38,10 +41,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"

Expand All @@ -53,9 +56,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"
2 changes: 1 addition & 1 deletion report/loglive/classes/table_log.php
Expand Up @@ -379,7 +379,7 @@ public function update_users_and_courses_used() {
$userfieldsapi->get_sql('', false, '', '', false)->selects . " 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()));
}
}

Expand Down
30 changes: 30 additions & 0 deletions report/loglive/tests/behat/loglive_report.feature
Expand Up @@ -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"
Expand Down Expand Up @@ -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
9 changes: 5 additions & 4 deletions report/progress/index.php
Expand Up @@ -344,13 +344,14 @@ function csv_quote($value) {
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 '<tr><th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.
$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></th>';
print '<tr><th scope="row"><a href="' . $CFG->wwwroot . '/user/view.php?id=' .
$user->id . '&amp;course=' . $course->id . '">' .
fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</a></th>';
foreach ($extrafields as $field) {
echo '<td>' . s($user->{$field}) . '</td>';
}
Expand Down Expand Up @@ -398,7 +399,7 @@ function csv_quote($value) {
$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);

Expand Down

0 comments on commit 266bcab

Please sign in to comment.