Hi,
This is not the most elegant solution for sure... but you can start with that.
I only put the way to get user data not the link to the quiz
SELECT u.firstname
,u.lastname
,u....
,ud1.data AS mycustomfield1
,ud2.data AS mycustomfield2
FROM mdl_user u
LEFT JOIN mdl_user_info_data ud1 ON u.id = ud1.userid AND ud1.fieldid = (SELECT id FROM mdl_user_info_field WHERE shortname = 'mycustomfield1')
LEFT JOIN mdl_user_info_data ud2 ON u.id = ud2.userid AND ud2.fieldid = (SELECT id FROM mdl_user_info_field WHERE shortname = 'mycustomfield2')
This is not the most elegant solution for sure... but you can start with that.
I only put the way to get user data not the link to the quiz
SELECT u.firstname
,u.lastname
,u....
,ud1.data AS mycustomfield1
,ud2.data AS mycustomfield2
FROM mdl_user u
LEFT JOIN mdl_user_info_data ud1 ON u.id = ud1.userid AND ud1.fieldid = (SELECT id FROM mdl_user_info_field WHERE shortname = 'mycustomfield1')
LEFT JOIN mdl_user_info_data ud2 ON u.id = ud2.userid AND ud2.fieldid = (SELECT id FROM mdl_user_info_field WHERE shortname = 'mycustomfield2')
I hope it will help.
Have a nice day.
Dominique.