Creating Moodle Users & Courses

Creating Moodle Users & Courses

by Tim Gustafson -
Number of replies: 1
Hi,

I was wondering if it is possible to:

- check for the existence of a Moodle user (indexed by e-mail address...so, "does bob@foo.com have an account")

- if the user doesn't exist, create the user and add them to the "course creators" group

- check for the existence of a Moodle course (indexed by course ID and quarter, so "is there an ABC101 course for Winter 2010")

- if the course doesn't exist, create the course

using some sort of web service or other API. I tried reading through the documentation on moodle.org and have found that it appears that this sort of integration is planned for Moodle 2.0, but perhaps not available in version 1.9.7?
Average of ratings: -
In reply to Tim Gustafson

Re: Creating Moodle Users & Courses

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
No. This sort of thing does not exist out-of-the-box in Moodle 1.9.

It is very easy to knock up a script like local/myws/addcourescreator.php that acts as a REST web service, and which

1. Does some sort of security check that the request is valid. (IP address of the caller in a whitelist, and password check would probably do.)

2. Checks whether the user exists.

3. If not, adds them, and gives them the course creator role in the system context.

It is probably about a dozen lines of code.


For creating courses, you might be able to do it using the the database enrolment plugin. That can automatically create courses if they exist in another database and do not exist in Moodle.


Also, there are various third-party web services plugins for Moodle 1.9 that might do what you want, but I don't know.