What is the MySQL query to add/remove a course for a user?

What is the MySQL query to add/remove a course for a user?

by dirty slit -
Number of replies: 2
pretty basic questions:

What is the MySQL query to add a course for a user?


and also, what would be the MySQL query to delete a course for a user?




P.S. Please include any other queries on this topic that you think might be useful for me dealing with courses and permissions and users.
Average of ratings: -
In reply to dirty slit

Re: What is the MySQL query to add/remove a course for a user?

by Hubert Chathi -
In general, you should not be executing SQL queries directly. Instead, you should be using the Moodle API calls. In this case, you probably want to use enrol_into_course, and role_unassign for enrolling and unenrolling a user, respectively. Both of these functions are in lib/accesslib.php
In reply to Hubert Chathi

Re: What is the MySQL query to add/remove a course for a user?

by Nour Omran -
hi
i wish u can help me in the following issue:


i want to make a specific criteria for question's name like the following
"courseshortname.categoryname.questionid.grade"


the problem is that i can't get the id until the question is being insertde in DB, so i think i need to update the question ater its being inserted and update its name

what do you think?? and where can i make that operation??

thank u all....