-
Notifications
You must be signed in to change notification settings - Fork 25
Installation Moodle Side
The following instructions describe how to setup Moodle so that it can connect to Drupal.
In this example Drupal is installed at http://localhost and moodle is installed at http://localhost/moodle.
Versions are listed for reference only as these were the versions when this documentation was created.
- Moodle 2.3.2+
- moodle-drupalservices auth plugin.
- Drupal services setup and working. Refer to Installation Drupal side.
Download and extract moodle-drupalservices into the auth/ directory. If necessary, change the extracted directory to drupalservices so that the directory structure looks something like;
auth/drupalservices/:
auth_drupalservices_sync_users.php
auth.php
config.html
lang
REST-API.php
README.md
In Moodle goto Site administration -> Plugins -> Authentication -> Manage authentication
You should see Drupal Services listed as an available plugin. Click on the Setings for Drupal Services.
In the plugin settings form, we need to tel Moodle how to connect to Drupal.
- Drupal Hostname
- Endpoint
- Remote user
- Remote user password
For this example, the following values can be used.
- Drupal Hostname: http://localhost
- Endpoint: /drupalservice
- Remote user: remote
- Remote user password: whatever you set as the remote user password.
Lock the following fields.
- First name
- Surname
- Email address
- City/town
- Country
- ID number IMPORTANT!!!! Lock the ID Number field! This field is being used to store the drupal uid for each user.
Save changes.
Enable the Drupal services plugin.
You need to run the sync script periodically so Moodle users get synced with Drupal users. The code has been changed so that new Drupal users will only be created in Moodle by the sync script. This may be changed in the future.
The script needs to be run from the command line and is usually done with cron.
The script can also be used to debug your installation. If the script can connect to Drupal and update the users then all is looking good.
If you have shell access, go to the command prompt and cd into the drupalservices directory and type the following. This assumes you are using sudo.
$sudo -u www-data /usr/bin/php /yourpathtomoodle/auth/drupalservices/auth_drupalservices_sync_users.php
Check the output for any errors. You should see something like;
RemoteAPI Object
(
[gateway] => http://localhost
[endpoint] => /drupalservice
[status] => 1
[session] => SESS49960de5880e8c687434170f6476605b
[sessid] => 9fiVVIMrT3WEwbVdPC3R2Ic6IOPxYqlmmY4qwTqSpP8
)
User entries to update: 4
Updated user admin(1)
Updated user user1(2)
Updated user user2(3)
Updated user remote(4)
Logged out from drupal services
If OK, set up cron. Below is an example only.
* Sample cron entry:
* # 5 minutes past the hour
* 5 * * * * $sudo -u www-data /usr/bin/php /yourpathtomoodle/auth/drupalservices/auth_drupalservices_sync_users.php
- Logout of moodle
- Login to drupal, then go to moodle and see if you are logged in automatically.
- Your account should be created if not already in Moodle.
- Logout and see if you logged out from drupal as well.
- If all goes well, you can set alternateloginurl under Manage authentication to point to the drupal login page.
- e.g. http://localhost/user/login. This means that drupal will do all logins.