Skip to content

Commit

Permalink
MDL-77353 core: examples of new user function usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Nguyen committed May 24, 2023
1 parent f897ecd commit 1452caa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1183,9 +1183,10 @@ protected function course_contacts(core_course_list_element $course) {
return $role->displayname;
}, $coursecontact['roles']);
$name = html_writer::tag('span', implode(", ", $rolenames).': ', ['class' => 'font-weight-bold']);
$name .= html_writer::link(new moodle_url('/user/view.php',
['id' => $coursecontact['user']->id, 'course' => SITEID]),
$coursecontact['username']);
$name .= html_writer::link(
\core_user::get_profile_url($coursecontact['user'], context_system::instance()),
$coursecontact['username']
);
$content .= html_writer::tag('li', $name);
}
$content .= html_writer::end_tag('ul');
Expand Down
13 changes: 9 additions & 4 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ public function print_toggle($type) {
public function get_left_rows($displayaverages) {
global $CFG, $OUTPUT;

// Course context to determine how the user details should be displayed.
$coursecontext = context_course::instance($this->courseid);

$rows = [];

$showuserimage = $this->get_pref('showuserimage');
Expand Down Expand Up @@ -703,14 +706,16 @@ public function get_left_rows($displayaverages) {
$usercell->scope = 'row';

if ($showuserimage) {
$usercell->text = $OUTPUT->user_picture($user, ['link' => false, 'visibletoscreenreaders' => false]);
$usercell->text = $OUTPUT->render(\core_user::get_profile_picture($user, $coursecontext, [
'link' => false, 'visibletoscreenreaders' => false
]));
}

$fullname = fullname($user, $viewfullnames);
$usercell->text = html_writer::link(
new moodle_url('/user/view.php', ['id' => $user->id, 'course' => $this->course->id]),
$usercell->text . $fullname,
['class' => 'username']
\core_user::get_profile_url($user, $coursecontext),
$usercell->text . $fullname,
['class' => 'username']
);

if (!empty($user->suspendedenrolment)) {
Expand Down
4 changes: 2 additions & 2 deletions user/classes/table/participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ public function col_select($data) {
*/
public function col_fullname($data) {
global $OUTPUT;

return $OUTPUT->user_picture($data, array('size' => 35, 'courseid' => $this->course->id, 'includefullname' => true));
return $OUTPUT->render(\core_user::get_profile_picture($data, null,
['courseid' => $this->course->id, 'includefullname' => true]));
}

/**
Expand Down

0 comments on commit 1452caa

Please sign in to comment.