Enroll Users to an Existing Course Through a Database

Enroll Users to an Existing Course Through a Database

by Ingrid Gustafson -
Number of replies: 18
Hi,

I am looking to add an entire class of students (i.e. graduating class of 2010) to a course that has already been created by the teacher. All of the students are already in our Moodle system, just not in this course.

I have an external SIS that has allowed me to export a list of all the students in this class in the following format:

Average of ratings: -
In reply to Ingrid Gustafson

Re: Enroll Users to an Existing Course Through a Database

by Manuel NT -

 Hi , if this  users area already on moodle  you can add to another course by simple sql statments; Here I add users , enrol users and create couses  directly  by SQL , I create  some  functions to  take users  from a  course to another  , etc..   Follow  this steps :

1 - If  your  users  are already on moodle , you need only follow  informations :

 field id from  user :  mdl_user

field id from context : mdl_context   to your  course;

role = 5  (student)

Then you  create a simple SQL to  insert these  datas on mdl_role_assignments ;

If  you have any more specific question ;  tell me.

Ag=fter that , your  users are enrolled  on the other course as  students;

In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Zachary Baiel -
Thanks for the information Manuel. I was actually looking for this exact solution. However, is editing the database via SQL the only way to accomplish this? That seems a bit scary to me.

The code doesn't look that bad, but when you edit the database directly, one slip in your SQL may ruin the entire database.
In reply to Zachary Baiel

Re: Enroll Users to an Existing Course Through a Database

by Manuel NT -
 I create php functions , that functiosn run SQL to create users,create courses ,categories, enrol and  update data  between a mssql database and  moodle into  mysql , I do  everything with my scripts and  on moodle  all user added and  enrolled  work  well , I make some checks before  insert  and update  database via  php of course ; Your  problem make easely  solved  like this , if  you nedd  i can show  you some  functions , It  will  guide you ...  I receive great  help from Antony Borrow and Miguel Santos ; He show me some  examples and  I can create my own scripts  with then...
In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Ingrid Gustafson -
Thank you for your responses - I had to present at a conference and haven't been able to keep up checking the forum!

If I understand this correctly, I'd need to have access to the database on the server to edit the file directly. Is there a ways I can do this (add the students) without having direct access to the server?

Thanks!

Ingrid
In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Armandt Slabbert -
Hi there, I'm a developer and new to Moodle. I've search for days now to find a solution like you just mentioned above. Could you please help me on how to add a user directly into the Moodle db and assigning them to a already created course. The scenario is like this. My client has a separate website where he advertises his courses. He also has a Moodle account/website with his current courses and students. Now when people goes to his separate website, they can select a course and register. I then have to take this user through a payment process and then manully insert them into my client's Moodle site and manually enroll them to this spesific course. Could you please help me with this. I got the part working where I need to insert the user into the Moodle db, but the enrollemnt part is unfimiliar to me. Thank you!!
In reply to Armandt Slabbert

Re: Enroll Users to an Existing Course Through a Database

by Richard Standen -
One approach would be to have your separate website not insert the user or enrollment data into the Moodle db, but to insert it into your own database. Then use Moodle admin to set-up external authentication and enrolment. External authentication works really well in Moodle, and this way, you're less likely to have this integration break on upgrade.

We do something similar. We then manage our external database with the open source xataface framework - http://www.xataface.com/. With their new email module, you get a really good system.

Hope that helps?

Richard
www.coursemerchant.com
In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by gopal dara -

Hello Sir,

I am trying to add users and course id through sql insert query.

Please let me know, what tables i need to use to update that information.

Thanks

VD

In reply to gopal dara

Re: Enroll Users to an Existing Course Through a Database

by mousam kumari -

Hi, I need to enrol users from Joomla to Moodle into specific courses for the role of teacher and student.The users are assigned roles in Joomla but I dont have idea how to map the same roles in Moodle automatically.I am using Joomdle for SSO with Joomla and Moodle.

Please help!!!

Thanks

In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Ajeet Kumar -

Kindly provide this function

 

In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Salman Zaidi -

Hi Manuel

This is Salman. I am new to moodle.  I am facing the same scenario of requirements,

I need to integrate moodle (which I have configured on MySQL) to the MSSQL Server db which already has information regarding courses, enrollments and users (learners). I need to display all those courses category wise on moddle site and take the learner onto them from moodle website. If the learner is already in MSSQL db, moodle should not allow him re register himself. Otherwise learner can register himself on moodle and he can select his course of interest. Once he select the course, his new user information and course enrollment should also be reflected into MSSQL server db.

Are you still into this business, I need you help in PHP as you have already done this type of work.

Yours response will be much appreciated.

Thanks

In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by Salman Zaidi -

Hi Manuel

I am new to moodle.  I am facing the same scenario of requirements,

I need to integrate moodle (which I have configured on MySQL) to the MSSQL Server db which already has information regarding courses, enrollments and users (learners). I need to display all those courses category wise on moddle site and take the learner onto them from moodle website. If the learner is already in MSSQL db, moodle should not allow him re register himself. Otherwise learner can register himself on moodle and he can select his course of interest. Once he select the course, his new user information and course enrollment should also be reflected into MSSQL server db.

Are you still into this business, I need you help in PHP as you have already done this type of work.

Yours response will be much appreciated.

Thanks


In reply to Manuel NT

Re: Enroll Users to an Existing Course Through a Database

by navya k -
The solution you mentioned is not working.. we need a php script to create users and enrol them to course from database...


plz suggest me

In reply to navya k

Re: Enroll Users to an Existing Course Through a Database

by Maxime Pelletier -

Hi,

In the original problem, users already exist in Moodle so the solution proposes work well.

In your case, you should also activate the Authentication plugin named "External Database" to import your users. You might need to create an SQL view to list your users.

Regards

In reply to Ingrid Gustafson

Re: Enroll Users to an Existing Course Through a Database

by krishna m -

Right now we want same kind of solution. I appreciate if you can share the sql script.

 

Your response greatly appreciate...

 

Thanks

 Krishna

In reply to krishna m

Re: Enroll Users to an Existing Course Through a Database

by Steve Finley -

I need the same script/help/advice from anyone that knows how to do this. As I am just starting to use Moodle...anyone have the exact steps I need to take?

 

Your help is much appreciated,

Steve

In reply to Ingrid Gustafson

Re: Enroll Users to an Existing Course Through a Database

by Dennis Arriola -

Hi! How can i display the list of course a certain student is enrolled?
please help.. Thanks

In reply to Dennis Arriola

Re: Enroll Users to an Existing Course Through a Database

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Click on their profile - they are all listed right there.