Databases: direct data insert into moodle db via SQL query

Databases: direct data insert into moodle db via SQL query

by Baber Ahmed -
Number of replies: 10

Hi All,

I have a question about tables and fields for adding a student from a stand alone form with a direct SQL query into the moodle database.

I have all the details like a UserName, Password (text password chosen by user)  and student details in a form, what I want to do is add those details to a course I have already setup in my moodle.

Is anyone able to give me advice on what tables and fields that I will need to set in my SQl query? Also will I need to do anything special with any of the fields like the password field etc...

I am also looking at SOAP->wspp but would perfer to write my own SQL query smile.

Any help would be most welcome
Bob

Average of ratings: -
In reply to Baber Ahmed

Re: Databases: direct data insert into moodle db via SQL query

by Paul Young -

you will need work with mdl_user using SQL. I don't think you can set up password for each individual in this way (but I could be wrong).

An alternative way is to upload users by visiting Site Administration, which is fairly easy too.

Paul

 

In reply to Paul Young

Re: Databases: direct data insert into moodle db via SQL query

by Baber Ahmed -

Hi Paul,

Thanks you replying! I have just been looking at mdl_user table smile... looks like I am looking at the right area at least.

The password field holds what looks to be the encrypted string of the password rather than the password sad

I am also looking for the table(unless its a field in mdl_user) that links the mdl_user record to a course, no luck so far on this.

Thanks in advance for your help
Bob

In reply to Baber Ahmed

Re: Databases: direct data insert into moodle db via SQL query

by Marin Sok -

Pual,

you can encript through PHP with MD5 function.

 

In reply to Marin Sok

Re: Databases: direct data insert into moodle db via SQL query

by Baber Ahmed -

Hi Marin,

If I encrypt the password that I have collected on my form using the MD5 function will it be compatible with Moodle login?

Please forgive me if this a stupid question but I am new to moodle but pretty comfortable with PHP.

Kind Regards
Bob

In reply to Baber Ahmed

Re: Databases: direct data insert into moodle db via SQL query

by Marin Sok -

It should be.

If you look into mdl_user, you  will see the first row of that table indicate moodle admin account was created prio moodle installation. The password word culumn is encripted. By the way, it is working for me thus.

In reply to Marin Sok

Re: Databases: direct data insert into moodle db via SQL query

by Baber Ahmed -

cool MD5 is working like a treat, I wrote a quick spcript to edit user passwords and have had some fun experimenting!

Thank you so much smile

In reply to Baber Ahmed

Re: Databases: direct data insert into moodle db via SQL query

by Paul Young -

check mdl_data_records table.

In reply to Paul Young

Re: Databases: direct data insert into moodle db via SQL query

by Baber Ahmed -

Hi Paul,

I have looked at the table you sugested and it has no records... sad

Any other palces I could look at to see how a user in linked to a course in the database.

Thanks in advance for your help
Bob

In reply to Baber Ahmed

Re: Databases: direct data insert into moodle db via SQL query

by Paul Young -

Sorry I misunderstood your question. Check mdl_course_display