Databases: mdl_user and mdl_course enrollment

Databases: mdl_user and mdl_course enrollment

av Kelly Turner -
Antall svar: 2

Can anyone help me.  I have been playing with PYP trying to understand what data is in what tables and how they relate.  I have run into a problem. 

Our user are in the mdl_user table.  This table contains the mdl_user.id field. 

Our historical data is in the mdl_log.  I can query by mdl_log.userid (this is the same data as the mdl_user.id), The mdl_log also has the mdl_log.course field (this field shows the tbl_mdl_course.id field)  By creating a join between the mdl_log and the mdl_course tables I can view the course and individual viewed and the time they did it.

Here is my problem.  I need to built a query that will show me the individuals enrolled in a particular course.  I can't seem to find a record that would show the Student userid's enrolled in a particular course. 

Can anyone help me?

Gjennomsnittlig vurdering: -
Som svar til Kelly Turner

Re: Databases: mdl_user and mdl_course enrollment

av Tim Hunt -
Bilde av Core developers Bilde av Documentation writers Bilde av Particularly helpful Moodlers Bilde av Peer reviewers Bilde av Plugin developers
This is a fairly frequently asked question, so a search should find you a detailed answer. The short and cryptic answer is you need mdl_role_assignments and mdl_context where contextlevel = 50.
Som svar til Tim Hunt

Re: Databases: mdl_user and mdl_course enrollment

av Kelly Turner -

Thank you so much.  With this response and another one you posted in reply to SQL query to find currently enrolled students dated 12/6/2007, I was able to understand this relationship.

I'm attaching a layout image of an external database with table exported from PHP and how the relationships are working for me. 

Vedlegg Table_Relationship.gif