Best practice for external fields from another table

Best practice for external fields from another table

by Kristaps Muižnieks -
Number of replies: 2

Good day developers!


A time ago I have made some new authorization that uses external API. API returns user data and ID number from the second system. According to all info, it's bad to add columns to the core database table, so I have made a new table for this that contains user class, school name, and external ID number. Bad thing is that, well I can store ID numbers in the moodle core system but the thing is that I need a class name that should be shown on all grading pages and also accepted in searching forms. I have already checked Moodle Additional user fields but will they show in the grading table next to users? 

Don't throw a link with a page that contains info about user profile fields, I have checked that already, problem is that I store these custom fields in another custom table. 

So what is the best practice to store additional data in a new table and let moodle find those fields?


Thanks.

Average of ratings: -
In reply to Kristaps Muižnieks

Re: Best practice for external fields from another table

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Off the top of my head, this doesn't sound like something that is possible to do without making changes to the core Moodle code.

If you want extra fields to appear on the grading table, outside of a small number that can be configured in the admin settings (search for 'showuseridentity' for the limited list of extra fields from the user table that can be included), then you are likely to have to modify the gradebook code to do this. That is true whether the extra fields are stored in a custom table or if they are stored using the standard "custom user profile fields" feature.