database enrolment table - what are the tables involved?

database enrolment table - what are the tables involved?

by Jerry Lau -
Number of replies: 3

Hello.

I used to have a script that ran for years to change all database enrolment type to the course's manual enrolment id instead so users can remove students at their leisure.

now running moodle 3.6.9

Now, the script does not work and noticed there is no such thing as "enrol_database" in the component field in the role_assignment table.

What happened and what tables are now involved when database enrolment is assigned other than course, role_assignment, context, etc?

thanks!



Average of ratings: -
In reply to Jerry Lau

Re: database enrolment table - what are the tables involved?

by Howard Miller -
Piksa bilong Core developers Piksa bilong Documentation writers Piksa bilong Particularly helpful Moodlers Piksa bilong Peer reviewers Piksa bilong Plugin developers

And possibly  https://docs.moodle.org/dev/New_enrolments_in_2.0 (I'm assuming that your code may have been from a VERY long time ago)
In reply to Howard Miller

Re: database enrolment table - what are the tables involved?

by Jerry Lau -
what happened to the value "enrol_database" in the field/column called 'component' in role_assignment table?

I can't remember what the columns called context id, contextlevel, and itemid does and how they are tied to the type of enrolment for that student.

Here is my query

SELECT mra.id as MRAID, mra.roleid as mraroleid, mra.contextid as mracontextid, mra.userid, mra.component as componentlng, mra.itemid as mraitemid, mc.id as MCID, mc.contextlevel as mccontextlevel, mc.instanceid, mue.id, mue.status, mue.enrolid, mue.userid as theuserid

FROM
mdl_role_assignments mra, mdl_context mc, mdl_user_enrolments mue

WHERE
mra.roleid = '5' and
mra.contextid = mc.id and
mra.component = 'enrol_database' and
mra.itemid = mue.enrolid and
mra.itemid = 'xxxxxxx' and
mra.userid = mue.userid and
mc.contextlevel = '50';

thanks!
In reply to Jerry Lau

Re: database enrolment table - what are the tables involved?

by Jerry Lau -
I figured it out.. nothing wrong with my query but in my logic, I deleted the component field first before I queryied it again