Moodle

Interact with Moodle LMS - Complete Integration (v0.1.0)

Overview

This node integrates with the Moodle Learning Management System (LMS) to perform various operations on Moodle resources. Specifically, for the User - Update operation, it allows updating details of an existing user in Moodle by specifying the user ID and any additional fields to modify.

Typical use cases include:

  • Updating user profile information such as address, phone numbers, timezone, or department.
  • Modifying user metadata like institution, description, or ID number.
  • Automating user data synchronization between Moodle and other systems.

For example, you might update a user's postal address and phone number after receiving updated contact info from your HR system.

Properties

Name Meaning
User ID The unique identifier of the user to update.
Additional Fields Optional collection of user attributes to update. These include:
- Address: Postal address of the user
- City: City of the user
- Country: Country code (e.g., US, GB, FR)
- Department: Department of the user
- Description: User bio or description
- ID Number: Arbitrary ID number (e.g., student or employee ID)
- Institution: Institution the user belongs to
- Mobile Phone: Mobile phone number
- Phone: Primary phone number
- Timezone: User's timezone (e.g., America/New_York)

Output

The output is a JSON object representing the updated user data as returned by the Moodle API. It typically includes the user's properties after the update.

Example structure (simplified):

{
  "id": 123,
  "username": "jdoe",
  "firstname": "John",
  "lastname": "Doe",
  "email": "[email protected]",
  "address": "123 Main St",
  "city": "Anytown",
  "country": "US",
  "department": "Sales",
  "description": "Updated user bio",
  "idnumber": "EMP00123",
  "institution": "Example Corp",
  "phone1": "555-1234",
  "phone2": "555-5678",
  "timezone": "America/New_York"
}

If the update is successful, the response reflects the new state of the user. If no changes are made or the user ID does not exist, the output may vary depending on Moodle's API response.

Dependencies

  • Requires a valid connection to a Moodle instance with web services enabled.
  • Needs an API key credential configured in n8n to authenticate requests to Moodle's REST API.
  • The Moodle site must have the appropriate permissions set to allow user updates via the API.

Troubleshooting

  • Common issues:

    • Invalid or missing User ID will cause the update to fail.
    • Insufficient permissions in Moodle for the API user to update users.
    • Incorrect field values (e.g., invalid country codes or timezones) may be rejected by Moodle.
    • Network connectivity or authentication errors with the Moodle API.
  • Error messages:

    • "User not found": Verify the User ID exists in Moodle.
    • "Permission denied": Check that the API credentials have rights to update users.
    • "Invalid parameter": Confirm all provided fields conform to expected formats.
  • Resolution tips:

    • Double-check the User ID and ensure it is correct.
    • Ensure the API token has sufficient privileges.
    • Validate input fields before sending the request.
    • Review Moodle logs for detailed error information if available.

Links and References


This summary focuses exclusively on the User - Update operation of the Moodle node based on the provided source code and property definitions.

Discussion