Enrollment API

Enrollment API

enrol_manual_enrol_users

This function manually enrols one or more users into a specified course with a specific role.

Let's review the POST parameters for this function:

  1. Required Parameters:
    • enrolments[0][roleid]= int (Required: The numeric ID for the role to assign, e.g., 5 for 'Student'.)
    • enrolments[0][userid]= int (Required: The numeric ID of the user to enrol.)
    • enrolments[0][courseid]= int (Required: The numeric ID of the course.)
  2. Optional Parameters:
    • enrolments[0][timestart]= int (Optional: A Unix timestamp for when the enrolment should begin.)
    • enrolments[0][timeend]= int (Optional: A Unix timestamp for when the enrolment should end.)
    • enrolments[0][suspend]= int (Optional: Set to 1 to make the enrolment suspended, or 0 for active.)

cURL Command Example (Enrolling a User):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=enrol_manual_enrol_users" \
-d "enrolments[0][roleid]=5" \
-d "enrolments[0][userid]=123" \
-d "enrolments[0][courseid]=789"



core_enrol_get_enrolled_users

This function retrieves a list of all users who are enrolled in a specific course.

Let's review the POST parameters for this function:

  1. Required Parameter:
    • courseid= int (Required: The numeric ID of the course.)

cURL Command Example (Getting Enrolled Users):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=core_enrol_get_enrolled_users" \
-d "courseid=789"



enrol_manual_unenrol_users

This function manually removes one or more users from a specified course.

Let's review the POST parameters for this function:

  1. Required Parameters:
    • enrolments[0][userid]= int (Required: The numeric ID of the user to be unenrolled.)
    • enrolments[0][courseid]= int (Required: The numeric ID of the course from which to unenrol the user.)

cURL Command Example (Unenrolling a User):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=enrol_manual_unenrol_users" \
-d "enrolments[0][userid]=123" \
-d "enrolments[0][courseid]=789"
    • Related Articles

    • Grades API

      gradereport_overview_get_course_grades This function retrieves an overview of all final course grades for a specific user. Let's review the POST parameters for this function: Optional Parameter: userid= int (Optional: The numeric ID of the user. If ...
    • User API

      core_user_create_users We advise the use of a developer to help you setup your API connection. This example shows how to create new users. Let's review the POST parameters for this function: Required Parameters: users[0][username]= string (Required: ...
    • Generate your API Key

      Step 1: Click on "Site admin" > "Integrations" > "Manage tokens": Step 2: Click on "Create Token": Step 3: (1) Select the user you wish to give the API Token to, (2) Select "API" then (3) Save: Step 4: Share this token with the user or save it if ...
    • Setting Up Your API

      We advise the use of a developer to help you setup your API connection. We will offer an example of how to CREATE A NEW USER on your LMS using a cURL command. Let's review the required POST parameters for the core_user_create_users function: ...
    • SCORM API

      mod_scorm_get_scorm_user_data This function retrieves detailed user tracking data for a specific attempt on a SCORM package. Let's review the POST parameters for this function: Required Parameters: scormid= int (Required: The numeric instance ID of ...