Skip to content

Commit

Permalink
Do not always show 'My certificates' profile link (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Jan 4, 2024
1 parent 22a84c5 commit 57e4f10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,16 @@ function customcert_extend_settings_navigation(settings_navigation $settings, na
* @param stdClass $user user object
* @param bool $iscurrentuser
* @param stdClass $course Course object
* @return bool
* @return void
*/
function mod_customcert_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
global $USER;

if (($user->id != $USER->id)
&& !has_capability('mod/customcert:viewallcertificates', context_system::instance())) {
return;
}

$params = [
'userid' => $user->id
];
Expand Down
13 changes: 13 additions & 0 deletions tests/behat/my_certificates.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ Feature: Being able to view the certificates you have been issued
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
| student1 | C2 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
Expand All @@ -37,3 +39,14 @@ Feature: Being able to view the certificates you have been issued
And I follow "My certificates"
And I should see "Custom certificate 1"
And I should see "Custom certificate 2"

Scenario: User does not see link for another user's certificates
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Custom certificate 1"
And I press "View certificate"
And I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Participants"
And I follow "Student 1"
And I should not see "My certificates"

0 comments on commit 57e4f10

Please sign in to comment.