There is something wrong with this SQL still though ... it mostly works
but I'm still getting wierd behaviour with small numbers of users.
Need some help here ... for example just look at get_site_users()
on your test site.
It's supposed to return a list of users who are admins, creators,
teachers or students
Moodle tables.
ie user -> userid in many tables, plus in user_students
start -> starttime and end -> endtime
I've just done all this as carefully as I could ... I don't think
I missed anything but it's pretty intensive work and I'd be fooling myself
if I didn't think I'd missed a couple.
Note that this version should pretty much be able to bootstrap itself
using PostgreSQL now ... but this is untested