How to use API Functions in my files?

How to use API Functions in my files?

von Teo Iovine -
Anzahl Antworten: 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.

Als Antwort auf Teo Iovine

Re: How to use API Functions in my files?

von David Mudrák -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Moodle HQ Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers Nutzerbild von Plugins guardians Nutzerbild von Testers Nutzerbild von 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.