Custom user fields in Quiz reports

Custom user fields in Quiz reports

by Kushan Rathnasekara -
Number of replies: 1
I have to obtain quiz reports, including the custom user fields I made. How can i do that. Pls assist.
Average of ratings: -
In reply to Kushan Rathnasekara

Re: Custom user fields in Quiz reports

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
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')

I hope it will help.

Have a nice day.

Dominique.
Average of ratings: Useful (1)