Hi,
I'm working on a script to import students/faculty/classes from our existing SIS system (and eventually to synchronize them) and have hit a bit of a stumbling block when it comes to importing parents and assigning teacher roles to classes.
I understand the basics behind the mdl_users and mdl_role_assignments tables, but I suspect my confusion lies somewhere with the mdl_context_* tables. So if anyone can shed some light on this, I'd be grateful.
First question: I know how to add a user and a class manually. How to I assign this user the role of teacher for that class directly in the database?
Second question: How can I assign a user the role of parent (or rather, assign parents to a user)? I'd also want to do this directly in the database.
Any help would be greatly appreciated.
Jon - If I understand your question, the answer is sort of .. the constants to understand are found in acessslib.php. So the the instanceid for when the contextlevel is 30 is mdl_user id, the instanceid for contextlevel 50 is the mdl_course id, etc. Each capability can be defined or revoked at any given context. Does that make more sense?
25 // context definitions 26 define('CONTEXT_SYSTEM', 10); 27 define('CONTEXT_PERSONAL', 20); 28 define('CONTEXT_USER', 30); 29 define('CONTEXT_COURSECAT', 40); 30 define('CONTEXT_COURSE', 50); 31 define('CONTEXT_GROUP', 60); 32 define('CONTEXT_MODULE', 70); 33 define('CONTEXT_BLOCK', 80);
Jon - the mdl_role_assignments table holds the information about teacher, students, and other roles for a class. If you are interested, send me an email request for the sql I use to populate our system and I will show you what I do at the beginning of the year. I have comments explaining the steps so it should give you some insights into what tables contain the various pieces. Peace -Anthony