Lehonti
Lehonti

Reputation: 133

How to use moodle core and get rid of everything else?

(Using Moodle 2.4)

In my company we need to program a web app that uses moodle's inner mechanisms that manage courses, users, database connections, etc., but only that. Nothing else.

We want to get rid of YUI, the GUI, and anything graphical. We don't want $PAGE or anything similar since it doesn't have anything to do with the important data in moodle (users, course content, etc). We just want the core. We'll make a completely new frontend. We have our own framework.

Is there a PHP file(s) that we can include in our scripts, that lets us call some functions or send some commands to the moodle core, to create an user, get user listing, create a course, etc?

If so, which ones are they? Where to start?

I've been looking this for months; in handbooks, in moodle's documentation, etc. But I still don't have a straightforward answer.

I hope you know what I mean. Something like

require_once('moodle_core.php');
$MOODLE_CORE -> create_user('Joe Winston','JW','123Password');

Does such thing exist? Is there a tutorial or a book about that?

Upvotes: 0

Views: 669

Answers (1)

Jitendra Gaur
Jitendra Gaur

Reputation: 778

Moodle magic begins when you include main config file for example -

require_once 'config.php';

//load course lib file to use course related functions
require_once $CFG->dirroot.'/course/lib.php';

$course = new stdClass();
$course->category = 1;
$course->fullname = 'My_test_course';

create_course($course);

For detail functions look into moodle documentation - http://docs.moodle.org/dev/Core_APIs

Upvotes: 2

Related Questions