Merge branch 'MDL-69474-311' of https://github.com/NashTechOpenUniversity/moodle into MOODLE_311_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2021-03-15 16:54:51 +01:00
2 changed files with 27 additions and 10 deletions
+11 -10
View File
@@ -2526,14 +2526,11 @@ class core_renderer extends renderer_base {
$user = $userpicture->user;
$canviewfullnames = has_capability('moodle/site:viewfullnames', $this->page->context);
$alt = '';
if ($userpicture->alttext) {
if (!empty($user->imagealt)) {
$alt = $user->imagealt;
} else {
$alt = get_string('pictureof', '', fullname($user, $canviewfullnames));
}
} else {
$alt = '';
}
if (empty($userpicture->size)) {
@@ -2570,23 +2567,27 @@ class core_renderer extends renderer_base {
$output .= fullname($userpicture->user, $canviewfullnames);
}
// then wrap it in link if needed
if (!$userpicture->link) {
return $output;
}
if (empty($userpicture->courseid)) {
$courseid = $this->page->course->id;
} else {
$courseid = $userpicture->courseid;
}
if ($courseid == SITEID) {
$url = new moodle_url('/user/profile.php', array('id' => $user->id));
} else {
$url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $courseid));
}
// Then wrap it in link if needed. Also we don't wrap it in link if the link redirects to itself.
// It might not return page url in unit test.
if (PHPUNIT_TEST) {
if (!$userpicture->link ) {
return $output;
}
} else if (!$userpicture->link || $this->page->url == $url) {
return $output;
}
$attributes = array('href' => $url, 'class' => 'd-inline-block aabtn');
if (!$userpicture->visibletoscreenreaders) {
$attributes['tabindex'] = '-1';
@@ -129,3 +129,19 @@ Feature: Access to full profiles of users
And I log in as "student1"
And I view the "Student 2" contact in the message area
Then I should see "First access to site"
@javascript
Scenario: Accessibility, users can not click on profile image when on user's profile page.
Given I log in as "admin"
And I am on "Course 1" course homepage
When I navigate to course participants
Then "//img[contains(@class, 'userpicture')]" "xpath_element" should exist
And "//a/child::img[contains(@class, 'userpicture')]" "xpath_element" should exist
When I follow "Teacher 1"
Then I should see "Teacher 1"
And "//img[contains(@class, 'userpicture')]" "xpath_element" should exist
And "//a/child::img[contains(@class, 'userpicture')]" "xpath_element" should not exist
When I follow "Full profile"
And I should see "Teacher 1"
Then "//img[contains(@class, 'userpicture')]" "xpath_element" should exist
And "//a/child::img[contains(@class, 'userpicture')]" "xpath_element" should not exist