Prerequisites and Moodle Set-up

Before the integration can be configured in OpenEduCat, Moodle must expose its web service API and a token must be issued. All steps in this page are performed in Moodle by a site administrator.

Requirements

  1. Moodle 4.5 or later, reachable over HTTPS from the OpenEduCat server.

  2. Site administrator access to Moodle, to enable web services and create a token.

  3. The queue_job module in OpenEduCat, which the integration uses to run long syncs in the background.

  4. Optional — the local_wsattendance Moodle plugin, required only if attendance is synchronized.

  5. Optional — the openeducat_timetable module, required only if timetable sessions are pushed to the Moodle calendar.

Step 1 — Enable Web Services

In Moodle, go to Site administration ‣ Advanced features, tick Enable web services, and click Save changes.

../../_images/moodle_enable_webservices.png

Step 2 — Enable the REST Protocol

Go to Site administration ‣ Server ‣ Web services ‣ Manage protocols and enable REST protocol.

../../_images/moodle_manage_protocols.png

Step 3 — Create the External Service

Go to Site administration ‣ Server ‣ Web services ‣ External services and click Add.

  1. Name :- openeducat_integration

  2. Short name :- openeducat_integration

  3. Enabled :- Ticked.

  4. Authorised users only :- Recommended, so that only the dedicated service account can use the token.

../../_images/moodle_external_service.png

Step 4 — Add the Required Functions

Open the Functions link next to the new service and add the functions listed below. The Test Connection button in OpenEduCat verifies these 25 functions and warns about any that are missing.

Area

Functions

Site information

core_webservice_get_site_info

Users

core_user_create_users, core_user_update_users, core_user_get_users_by_field

Courses

core_course_create_courses, core_course_update_courses, core_course_get_courses_by_field

Categories

core_course_create_categories, core_course_update_categories, core_course_get_categories

Enrollment

enrol_manual_enrol_users, enrol_manual_unenrol_users, core_enrol_get_enrolled_users

Roles

core_role_assign_roles, core_role_unassign_roles

Groups

core_group_create_groups, core_group_add_group_members, core_group_get_course_groups

Grades

gradereport_user_get_grade_items, mod_assign_get_assignments, mod_assign_get_grades, mod_quiz_get_quizzes_by_courses, mod_quiz_get_user_best_grade

Completion

core_completion_get_course_completion_status, core_completion_get_activities_completion_status

Add these additional functions only if the matching feature is used:

Feature

Functions

Timetable sessions

core_calendar_create_calendar_events, core_calendar_delete_calendar_events

Attendance

mod_wsattendance_get_session, mod_wsattendance_update_user_status (provided by the local_wsattendance plugin)

../../_images/moodle_service_functions.png

Step 5 — Create the API Token

Go to Site administration ‣ Server ‣ Web services ‣ Manage tokens and click Create token.

  1. User :- The Moodle administrator, or a dedicated service account.

  2. Service :- openeducat_integration.

  3. IP restriction :- Optionally restrict the token to the OpenEduCat server’s IP address.

  4. Valid until :- Leave empty for a token that does not expire.

Copy the generated token — it is entered in OpenEduCat in the next chapter.

../../_images/moodle_create_token.png

Warning

If the token is later regenerated or deleted in Moodle, every sync fails with an authentication error until the new token is saved on the OpenEduCat instance record.

Step 6 — Note the Moodle Role IDs

Role IDs are not identical on every Moodle site. Go to Site administration ‣ Users ‣ Permissions ‣ Define roles and open the roles you use. The role ID is shown in the browser address bar, for example .../admin/roles/define.php?action=view&roleid=5.

The defaults used by OpenEduCat are 5 for Student and 3 for Editing teacher. If your site differs, correct them on the instance record before running any sync — a wrong role ID causes permission errors or silently failing enrollments.

Background Job Configuration

The integration hands long-running syncs to the queue_job module. On the OpenEduCat server, odoo.conf must run with multiple workers and load queue_job as a server-wide module:

workers = 4
server_wide_modules = base,web,queue_job

[queue_job]
channels = root:2,root.moodle:4

root.moodle:4 allows four Moodle sync jobs to run in parallel. Restart the OpenEduCat service after editing the configuration file.

Note

With workers = 0 the queue is not processed. Background syncs stay pending and only the Run Immediately mode of the manual sync wizard works.

Installing the Module

Once Moodle is prepared, install OpenEduCat Moodle Integration from Apps. Searching for moodle shows the core module and, when their dependencies are already installed, the gradebook and fees bridges install automatically.

../../_images/moodle_module_install.png