Moodle

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

Overview

This node integrates with the Moodle Learning Management System (LMS) to manage user enrollments in courses. Specifically, the Enroll User operation allows you to enroll a specified user into a course with a defined role such as Student, Teacher, Manager, or Course Creator.

Common scenarios where this node is beneficial include:

  • Automating enrollment of students into courses after registration.
  • Assigning teachers or managers to courses programmatically.
  • Managing course access dynamically based on external triggers or workflows.

For example, when a new student signs up on an external platform, this node can automatically enroll them into their selected courses in Moodle with the "Student" role.

Properties

Name Meaning
User ID The unique identifier of the user to enroll in the course.
Course ID The unique identifier of the course in which the user will be enrolled.
Role The role assigned to the user upon enrollment. Options: Student, Teacher, Manager, Course Creator

Output

The output JSON contains the response from the Moodle API for the enrollment request. Typically, it confirms successful enrollment or provides error details if the operation failed.

Since this operation interacts with Moodle's web service for manual enrollment, the output usually includes status information but does not contain binary data.

Example output structure (simplified):

{
  "status": "success",
  "message": "User enrolled successfully"
}

Or, if an error occurs:

{
  "error": "User is already enrolled in the course"
}

Dependencies

  • Requires a valid Moodle API authentication token configured in n8n credentials.
  • The Moodle instance must have the web service function enrol_manual_enrol_users enabled and accessible via the API.
  • Proper permissions are needed for the API user to enroll users in courses.

Troubleshooting

  • Common Issues:

    • Enrollment fails if the user or course ID does not exist.
    • Insufficient permissions for the API user to perform enrollment.
    • The user is already enrolled in the course.
    • Moodle web services not properly configured or disabled.
  • Error Messages & Resolutions:

    • "User is already enrolled in the course": Check if the user is already enrolled; avoid duplicate enrollments.
    • "Invalid user ID or course ID": Verify that the provided IDs are correct and exist in Moodle.
    • "Permission denied": Ensure the API credential has sufficient rights to enroll users.
    • "Web service function not available": Confirm that the Moodle site has the required web service functions enabled.

Links and References

Discussion