How to use API Functions in my files?

How to use API Functions in my files?

by Teo Iovine -
Number of replies: 1

Hello community. I don't have a single clue of how to access the moodle API files to use their functions. I have to use the context_course class because I need to get some enrolments, but I can't figure out how to include the API files in my files.

Thanks in advance.

Average of ratings: -
In reply to Teo Iovine

Re: How to use API Functions in my files?

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Many core libraries are loaded automatically during the script setup. This happens after you load config.php at the top of your script.

To obtain the instance of the course context object, you should be able to call something like

$coursecontext = context_course::instance($courseid, MUST_EXIST);

without any explicit library requirement. But we would need to know more about your issue to provide more helpful answer.