From 079e44b80b0677b1124720048e3f5f3e11c96e17 Mon Sep 17 00:00:00 2001 From: Sascha Vogel Date: Wed, 4 Mar 2026 15:20:36 +0100 Subject: [PATCH] Fix including custom profile fields (#123) --- classes/table/overview.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/table/overview.php b/classes/table/overview.php index 8e3557f552..0142d740d1 100644 --- a/classes/table/overview.php +++ b/classes/table/overview.php @@ -159,11 +159,13 @@ public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') { public function query_db($pagesize, $useinitialsbar = true) { global $DB; - $fields = \core_user\fields::for_userpic()->with_identity($this->context) - ->get_sql('u', false, '', '', false)->selects; + $userfields = \core_user\fields::for_userpic()->with_identity($this->context) + ->get_sql('u', true, '', '', false); $params = ['courseid' => $this->courseid]; + $params += $userfields->params; + $showinactive = !!get_config('block_completion_progress', 'showinactive'); $enroljoin = get_enrolled_with_capabilities_join($this->context, '', '', 0, !$showinactive); $params += $enroljoin->params; @@ -283,8 +285,8 @@ public function query_db($pagesize, $useinitialsbar = true) { } $this->rawdata = $DB->get_records_sql( - "SELECT DISTINCT $fields, l.timeaccess, b.percentage AS progress, b.timemodified AS progressage - FROM {user} u {$enroljoin->joins} {$fjoins} + "SELECT DISTINCT {$userfields->selects}, l.timeaccess, b.percentage AS progress, b.timemodified AS progressage + FROM {user} u {$enroljoin->joins} {$fjoins} {$userfields->joins} LEFT JOIN {user_lastaccess} l ON l.userid = u.id AND l.courseid = :courseid LEFT JOIN {block_completion_progress} b ON b.userid = u.id AND b.blockinstanceid = :bi WHERE {$enroljoin->wheres} AND {$twhere} AND ({$fwheres})