Skip to main content

Moodle LMS Destination

Nexla's bi-directional connectors allow data to flow both to and from any location, making it simple to create a FlexFlow data flow that sends data to a Moodle LMS location.
moodle_api.png

Moodle LMS

Create a Moodle LMS Destination

  1. Click the + icon on the Nexset that will be sent to the Moodle LMS destination, and select the Send to Destination option from the menu.

  2. Select the Moodle LMS connector from the list of available destination connectors. Then, select the credential that will be used to connect to the Moodle instance, and click Next; or, create a new Moodle LMS credential for use in this flow.

  3. In Nexla, Moodle LMS destinations can be created using pre-built endpoint templates, which expedite destination setup for common Moodle write operations. Each template is designed specifically for the corresponding Moodle web service function, making destination configuration easy and efficient.
    • To configure this destination using a template, follow the instructions in Configure Using a Template.

    Moodle LMS destinations can also be configured manually, allowing you to send data to Moodle endpoints not included in the pre-built templates or apply further customizations to exactly suit your needs.
    • To configure this destination manually, follow the instructions in Configure Manually.

Configure Using a Template

Nexla provides pre-built templates that can be used to rapidly configure destinations to send data to common Moodle LMS write endpoints. Each template is pre-configured for the corresponding Moodle web service function, making destination setup easy and efficient.

  • To configure this destination using a template, select the endpoint to which data will be sent from the Endpoint pulldown menu. Then, click on the template in the list below to expand it, and follow the instructions to configure additional endpoint settings.

    Create Users

    Creates new Moodle user accounts from records in the Nexset. Use this endpoint to provision users in Moodle from an HR system, student information system, or any external user directory. Each record in the Nexset should represent one user to be created.

    • Ensure each record in the Nexset includes the required Moodle user fields. At a minimum, each record must contain the following:

      • username — unique Moodle username (lowercase, no spaces)
      • password — initial password (must meet Moodle's password policy)
      • firstname — user's first name
      • lastname — user's last name
      • email — unique email address
    • Optional fields such as idnumber, city, country, lang, timezone, description, and custom profile fields can also be included in each record. Refer to the Moodle Web Services documentation for the full list of supported user fields.
    • No additional endpoint-level configuration parameters are required. Nexla sends one user record per API call to the core_user_create_users web service function.

    Moodle's core_user_create_users function enforces your site's password policy and will reject user records with passwords that do not meet the minimum requirements. Ensure passwords in the source data comply with the Moodle site's password policy before running this flow.

    Update Users

    Updates existing Moodle user profile fields from records in the Nexset. Use this endpoint to synchronize user profile changes from an authoritative source (such as an HR system or directory) into Moodle. Each record in the Nexset represents one user to be updated.

    • Each record in the Nexset must include the id field containing the numeric Moodle user ID of the user to be updated. This field is required for Moodle to identify which user account to modify.
    • Include only the fields that should be updated in each record. Moodle will update only the fields present in the request and leave all other fields unchanged.
    • Updatable fields include firstname, lastname, email, username, idnumber, city, country, lang, timezone, description, and custom profile fields.

    To retrieve the numeric Moodle user IDs needed for updates, use the Moodle LMS Get Users or Get Users by Field source endpoint first to build a lookup mapping external identifiers to Moodle user IDs.

    Enrol Users

    Manually enrols users into a course with a specified role. Use this endpoint to programmatically enrol learners in courses based on records from an HR system, registration platform, or other external system. Each record in the Nexset should represent one enrolment action.

    • Each record in the Nexset must include the following fields:

      • roleid — numeric Moodle role ID for the enrolment
      • userid — numeric Moodle user ID of the user to enrol
      • courseid — numeric Moodle course ID of the course to enrol the user in
    • Alternatively, set the Role ID configuration parameter at the endpoint level to apply a single role to all enrolments in this flow. Available role options are:

      • Student (5) — standard learner role (default)
      • Teacher (3) — editing teacher with full course management
      • Non-editing teacher (4) — teacher with grading access but no course editing
      • Manager (1) — site manager role
    • Optionally include timestart and timeend fields as Unix timestamps to define the enrolment period. If omitted, the enrolment will have no time restriction.

    This endpoint uses Moodle's manual enrolment plugin (enrol_manual_enrol_users). The manual enrolment method must be enabled on the target course in Moodle for enrolments to succeed. Confirm this under the course settings in Course administration > Users > Enrolment methods.

    Unenrol Users

    Removes user enrolments from a course. Use this endpoint to programmatically unenrol learners when they leave an organization, complete a program, or when enrolment records in an authoritative source are revoked. Each record in the Nexset should represent one unenrolment action.

    • Each record in the Nexset must include the following fields:

      • userid — numeric Moodle user ID of the user to unenrol
      • courseid — numeric Moodle course ID of the course from which the user will be unenrolled
    • No additional endpoint-level configuration parameters are required. Nexla sends one unenrolment record per API call to the enrol_manual_unenrol_users web service function.

    :::warning Important Unenrolling a user from a course in Moodle permanently removes their access to all course content and may affect their grade data visibility. Verify that the unenrolment records in the source Nexset are accurate before activating this flow. :::

    Create Courses

    Creates new courses in Moodle from records in the Nexset. Use this endpoint to provision courses programmatically from an external course catalogue, curriculum management system, or migration source. Each record in the Nexset represents one course to be created.

    • Each record in the Nexset must include the following required fields:

      • fullname — the full display name of the course
      • shortname — a unique short name for the course (no spaces, used in URLs)
      • categoryid — the numeric Moodle category ID under which the course will be created
    • Optional fields such as summary, format (e.g., topics, weeks), startdate (Unix timestamp), enddate (Unix timestamp), visible (0 or 1), and idnumber can also be included. Refer to the Moodle Web Services documentation for the full list of supported course creation fields.

    Course short names must be unique across the entire Moodle site. If a short name collision occurs, the API call will fail for that record. Review your source data for duplicate short names before activating this flow.

Configure Manually

Moodle LMS destinations can be manually configured to send data to any valid Moodle REST web service write endpoint. Using manual configuration, you can also configure Nexla to automatically send the response received from the Moodle API after each call to a new Nexla webhook data source.

API Method

  1. To manually configure this destination, select the Advanced tab at the top of the configuration screen.

  2. Select POST from the Method pulldown menu. All Moodle REST web service functions use POST, regardless of whether the operation creates, updates, or deletes data.

Data Format

  1. Select JSON from the Content Format pulldown menu. Nexla will automatically convert Nexset records to the JSON format expected by the Moodle REST web service layer before each API call.

API Endpoint URL

  1. Enter the URL of the Moodle REST server in the URL field using the format:

    https://<your-moodle-domain>/webservice/rest/server.php?wstoken=<your-token>&wsfunction=<function_name>&moodlewsrestformat=json

    Replace <your-moodle-domain> with your Moodle instance domain, <your-token> with the web service token from your credential, and <function_name> with the Moodle web service function to call (e.g., core_user_create_users, enrol_manual_enrol_users).

The Moodle REST endpoint requires the function name, token, and response format to be specified as URL query parameters. The record payload from the Nexset is sent in the POST request body. Refer to the Moodle Web Services developer documentation for the full list of available write functions and their required parameters.

Request Headers

Optional
  • If Nexla should include any additional request headers in API calls to this destination, enter the headers & corresponding values as comma-separated pairs in the Request Headers field (e.g., header1:value1,header2:value2).

    You do not need to include any headers already present in the credentials. Moodle REST API authentication is handled via the wstoken query parameter, which is managed automatically by the Nexla credential.

Exclude Attributes from the Call

Optional
  • If any record attributes in the Nexset should be omitted when sending data to this Moodle LMS destination, select the attributes from the Exclude Attributes pulldown menu.

  • Any number of attributes can be selected for exclusion, and all excluded attributes will be shown in the field. To remove an attribute from the list, click the X icon next to the attribute name.

Record Batching

Optional
  1. If records should be sent to this destination in batched API calls, check the box next to Would you like to batch your records together? to enable record batching.

  2. Enter the maximum number of records that should be batched together in a single API call in the Batch Size field. By default, this value is set to 100.

  3. Select the algorithm that will be used to group records into batches from the Grouping Algorithm pulldown menu. The sample request shown in the panel on the right will be updated to reflect the current batching settings. Some algorithms require additional settings—click on an algorithm listed below to view instructions for configuring these settings.

Moodle's bulk write functions (such as core_user_create_users) accept arrays of records in a single call. Enabling batching can significantly improve throughput when creating or updating many users or courses. Verify the batch format against the target Moodle function's documentation before enabling.

Response Webhook

Optional

Nexla can automatically send the response received from the Moodle LMS API after each call to a new Nexla webhook data source. This option allows you to keep track of the status of each API call and any additional information returned after each call — for example, the newly assigned Moodle IDs for created users or courses.

  • To enable this option, check the box next to Would you like to process the API response as a Nexla Webhook source?.

Sample Request Payload

Sample request payloads containing a portion of the Nexset data that will be sent to the Moodle LMS API endpoint based on the current settings are shown in the Sample Payload panel on the right. These samples can be referenced to ensure that the destination and request settings are correctly configured.

  • Click on a sample request payload to expand it and view the complete payload content.
  • Sample payloads are automatically updated with each setting change, making it easy to verify that changes achieve the desired effect.

Endpoint Testing (Manual Configuration)

After all endpoint settings have been configured, Nexla can send a test payload to the Moodle LMS API to ensure that the destination is configured correctly.

  1. To send a test payload, select the Test button at the top of the Sample Payload panel, and click on a listed sample payload to expand it.

  2. If any modifications to the sample payload are needed, make the necessary changes directly within the sample window.

  3. Click the Send Test Data button at the top of a sample payload to send the test payload to the Moodle LMS API using the current settings.

Save & Activate the Destination

  • Once all endpoint settings have been configured, click the Done button in the upper right corner of the screen to save and create the destination. To begin sending data to the configured Moodle LMS endpoint, open the destination resource menu, and select Activate.

    The Nexset data will not be sent to Moodle LMS until the destination is activated. Destinations can be activated immediately or at a later time, providing full control over data movement.