A great place to begin learning how data reports can be developed is with the Open University's Ad-hoc database queries plugin, available from the Moodle plugin directory at https://moodle.org/plugins/report_customsql. As this plugin essentially lets us query the Moodle database in any way we choose, along with providing the functionality to schedule report generation (including saving reports as a CSV file and emailing them out to a chosen recipient), it makes sense to use this plugin as the foundation for any reporting plugin we develop. To that end, rather than downloading the code from the plugin directory, we can fork it in GitHub. Go to https://github.com/moodleou/moodle-report_customsql and click on the Fork
button:
You can now clone your fork to your development machine. Moodle reports are copied into the /report
folder: