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.
In reply to Jon Cochran
Re: Importing parents/teachers and the whole context thing...
by Anthony Borrow -
John - I just posted on the topic of parents. I have done something similar for our SIS. I would be happy to email you a copy of the script that we use at the beginning of the year if you think it might help save you some time. Peace - Anthony
In reply to Anthony Borrow
Re: Importing parents/teachers and the whole context thing...
by Jon Cochran -
Anthony -- Thanks... Your script has been helpful with understanding parents...
Do the same concepts apply to teachers and classes, or am I going down the wrong alley with this?
Do the same concepts apply to teachers and classes, or am I going down the wrong alley with this?
In reply to Jon Cochran
Re: Importing parents/teachers and the whole context thing...
by Anthony Borrow -
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);
In reply to Anthony Borrow
Re: Importing parents/teachers and the whole context thing...
by Jon Cochran -
Does that make more sense?
Sort of, I suppose. I guess what I'm really after is this. I know how to create a course directly in the DB. I know how to create a teacher directly in the DB. How do I associate the teacher with that course?
In reply to Jon Cochran
Re: Importing parents/teachers and the whole context thing...
by Anthony Borrow -
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