Fix error message when we have custom profile fields (#465)

This commit is contained in:
hieuvu 2021-10-20 14:03:23 +07:00 committed by Mark Nelson
parent 18eab896bd
commit 2a9640b5a3
2 changed files with 17 additions and 4 deletions

View file

@ -274,11 +274,16 @@ class certificate {
$extrafields = \core_user\fields::for_identity($context)->get_required_fields();
$ufields = \core_user\fields::for_userpic()->including(...$extrafields);
$ufields = $ufields->get_sql('u', false, '', '', false)->selects;
$sql = "SELECT $ufields, ci.id as issueid, ci.code, ci.timecreated
[
'selects' => $userfieldsselects,
'joins' => $userfieldsjoin,
'params' => $userfieldsparams
] = (array) $ufields->get_sql('u', true);
$allparams = array_merge($allparams, $userfieldsparams);
$sql = "SELECT ci.id as issueid, ci.code, ci.timecreated $userfieldsselects
FROM {user} u
INNER JOIN {customcert_issues} ci
ON u.id = ci.userid
INNER JOIN {customcert_issues} ci ON u.id = ci.userid
$userfieldsjoin
WHERE u.deleted = 0
AND ci.customcertid = :customcertid
$conditionssql";

View file

@ -21,6 +21,8 @@ Feature: Being able to view the certificates that have been issued
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| customcert | Custom certificate 1 | Custom certificate 1 intro | C1 | customcert1 |
And the following config values are set as admin:
| showuseridentity | username,email |
Scenario: View the issued certificates
And I log in as "student1"
@ -38,6 +40,12 @@ Feature: Being able to view the certificates that have been issued
And I follow "Custom certificate 1"
And I should see "Student 1"
And I should see "Student 2"
And I should see "Email address"
And I should see "Username"
And "Student 1" row "Email address" column of "generaltable" table should contain "student1@example.com"
And "Student 1" row "Username" column of "generaltable" table should contain "student1"
And "Student 2" row "Email address" column of "generaltable" table should contain "student2@example.com"
And "Student 2" row "Username" column of "generaltable" table should contain "student2"
Scenario: Delete an issued certificate
And I log in as "student1"