MDL-77353 core: examples of new user function usage

This commit is contained in:
Nathan Nguyen 2023-03-09 15:40:36 +11:00
parent f897ecd627
commit 1452caac93
3 changed files with 15 additions and 9 deletions

View File

@ -1183,9 +1183,10 @@ class core_course_renderer extends plugin_renderer_base {
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');

View File

@ -621,6 +621,9 @@ class grade_report_grader extends grade_report {
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');
@ -703,14 +706,16 @@ class grade_report_grader extends grade_report {
$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)) {

View File

@ -250,8 +250,8 @@ class participants extends \table_sql implements dynamic_table {
*/
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]));
}
/**