WT JMoodle library
How to use Moodle connetction library in Joomla
Install and configure Moodle and Joomla
- Install a JMoodle library in Joomla
- Go to your Moodle and create token for Joomla
- Set this token to JMoodle library in system plugin settings
How to create a Moodle web services token for Joomla
To get a token, follow these steps:
- Create a special user in Moodle, on whose behalf Joomla will act in Moodle and access the REST API methods. Administration / Users / Accounts / Add User. Do not appoint this user as the site administrator.
- Create a role for a special Moodle user and assign her the necessary access rights in Administration / Users / Rights / Define roles. The presence or absence of accesses in this section (role context and rights) will affect the work with some REST API methods. The access rights required for the methods are visible at the stage of adding functions for the web service.
- Create an External service in Administration / Server / Web Services / External Services.
- After creating an external service from the list of external services, go to the functions of the created service and add the REST API methods necessary for the integration to work. Add the corewebservicegetsiteinfo method in order to see in Joomla that the integration really works, as well as a list of methods available for the REST API.
- Create a token in Administration / Server / Web Services / Tokens for a specially created user from under whom Joomla will access the REST API.
If you have done everything correctly, you will see a list of available Moodle REST API methods in your Joomla
How to make a request to Moodle webservices from Joomla via REST API?
$moodle = new JMoodle();
* Request method.
* @param string $method Moodle REST API method
* @param array $data data for Moodle REST API method
* @return array
$result_jmoodle = $moodle->request('core_webservice_get_site_info');
More info on docs page or GitHub