Enrollment API Enrollment Resource

With the Enrollment API Enrollment resource, you can complete the following tasks.

Get the User’s Enrollment Status in a Course

class enrollment.views.EnrollmentView(**kwargs)[source]

Use Case

Get the user’s enrollment status for a course.

Example Request

GET /api/enrollment/v1/enrollment/{username},{course_id}

Response Values

If the request for information about the user is successful, an HTTP 200 “OK” response is returned.

The HTTP 200 response has the following values.

  • course_details: A collection that includes the following values.

    • course_end: The date and time when the course closes. If null, the course never ends.

    • course_id: The unique identifier for the course.

    • course_modes: An array of data about the enrollment modes supported for the course. If the request uses the parameter include_expired=1, the array also includes expired enrollment modes.

      Each enrollment mode collection includes the following values.

      • currency: The currency of the listed prices.
      • description: A description of this mode.
      • expiration_datetime: The date and time after which users cannot enroll in the course in this mode.
      • min_price: The minimum price for which a user can enroll in this mode.
      • name: The full name of the enrollment mode.
      • slug: The short name for the enrollment mode.
      • suggested_prices: A list of suggested prices for this enrollment mode.
    • course_end: The date and time at which the course closes. If null, the course never ends.

    • course_start: The date and time when the course opens. If null, the course opens immediately when it is created.

    • enrollment_end: The date and time after which users cannot enroll for the course. If null, the enrollment period never ends.

    • enrollment_start: The date and time when users can begin enrolling in the course. If null, enrollment opens immediately when the course is created.

    • invite_only: A value indicating whether students must be invited to enroll in the course. Possible values are true or false.

  • created: The date the user account was created.

  • is_active: Whether the enrollment is currently active.

  • mode: The enrollment mode of the user in this course.

  • user: The ID of the user.

Example response showing the user’s enrollment status in a course

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS

{
    "created": "2014-11-19T04:06:55Z",
    "mode": "honor",
    "is_active": true,
    "course_details": {
        "course_id": "edX/DemoX/Demo_Course",
        "enrollment_end": null,
        "course_modes": [
            {
                "slug": "honor",
                "name": "Honor Code Certificate",
                "min_price": 0,
                "suggested_prices": [],
                "currency": "usd",
                "expiration_datetime": null,
                "description": null
            }
        ],
        "enrollment_start": null,
        "invite_only": false
    },
    "user": "staff"
}

Get the User’s Enrollment Information for a Course

class enrollment.views.EnrollmentCourseDetailView(**kwargs)[source]

Use Case

Get enrollment details for a course.

Response values include the course schedule and enrollment modes supported by the course. Use the parameter include_expired=1 to include expired enrollment modes in the response.

Note: Getting enrollment details for a course does not require authentication.

Example Requests

GET /api/enrollment/v1/course/{course_id}

GET /api/enrollment/v1/course/{course_id}?include_expired=1

Response Values

If the request is successful, an HTTP 200 “OK” response is returned along with a collection of course enrollments for the user or for the newly created enrollment.

Each course enrollment contains the following values.

  • course_end: The date and time when the course closes. If null, the course never ends.

  • course_id: The unique identifier for the course.

  • course_modes: An array of data about the enrollment modes supported for the course. If the request uses the parameter include_expired=1, the array also includes expired enrollment modes.

    Each enrollment mode collection includes the following values.

    • currency: The currency of the listed prices.
    • description: A description of this mode.
    • expiration_datetime: The date and time after which users cannot enroll in the course in this mode.
    • min_price: The minimum price for which a user can enroll in this mode.
    • name: The full name of the enrollment mode.
    • slug: The short name for the enrollment mode.
    • suggested_prices: A list of suggested prices for this enrollment mode.
  • course_start: The date and time when the course opens. If null, the course opens immediately when it is created.

  • enrollment_end: The date and time after which users cannot enroll for the course. If null, the enrollment period never ends.

  • enrollment_start: The date and time when users can begin enrolling in the course. If null, enrollment opens immediately when the course is created.

  • invite_only: A value indicating whether students must be invited to enroll in the course. Possible values are true or false.

Example response showing a user’s course enrollment information

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, HEAD, OPTIONS

{
    "course_id": "edX/DemoX/Demo_Course",
    "enrollment_end": null,
    "course_modes": [
        {
            "slug": "honor",
            "name": "Honor Code Certificate",
            "min_price": 0,
            "suggested_prices": [],
            "currency": "usd",
            "expiration_datetime": null,
            "description": null
        }
    ],
    "enrollment_start": null,
    "invite_only": false
}

View a User’s Enrollments or Enroll a User in a Course

class enrollment.views.EnrollmentListView(**kwargs)[source]

Use Cases

  • Get a list of all course enrollments for the currently signed in user.

  • Enroll the currently signed in user in a course.

    Currently a user can use this command only to enroll the user in the default course mode. If this is not supported for the course, the request fails and returns the available modes.

    This command can use a server-to-server call to enroll a user in other modes, such as “verified”, “professional”, or “credit”. If the mode is not supported for the course, the request will fail and return the available modes.

    You can include other parameters as enrollment attributes for a specific course mode. For example, for credit mode, you can include the following parameters to specify the credit provider attribute.

    • namespace: credit
    • name: provider_id
    • value: institution_name

Example Requests

GET /api/enrollment/v1/enrollment

POST /api/enrollment/v1/enrollment {

“mode”: “credit”, “course_details”:{“course_id”: “edX/DemoX/Demo_Course”}, “enrollment_attributes”:[{“namespace”: “credit”,”name”: “provider_id”,”value”: “hogwarts”,},]

}

POST Parameters

A POST request can include the following parameters.

  • user: Optional. The username of the currently logged in user. You cannot use the command to enroll a different user.

  • mode: Optional. The course mode for the enrollment. Individual users cannot upgrade their enrollment mode from the default. Only server-to-server requests can enroll with other modes.

  • is_active: Optional. A Boolean value indicating whether the enrollment is active. Only server-to-server requests are allowed to deactivate an enrollment.

  • course details: A collection that includes the following information.

    • course_id: The unique identifier for the course.
  • email_opt_in: Optional. A Boolean value that indicates whether the user wants to receive email from the organization that runs this course.

  • enrollment_attributes: A dictionary that contains the following values.

    • namespace: Namespace of the attribute
    • name: Name of the attribute
    • value: Value of the attribute
  • is_active: Optional. A Boolean value that indicates whether the enrollment is active. Only server-to-server requests can deactivate an enrollment.

  • mode: Optional. The course mode for the enrollment. Individual users cannot upgrade their enrollment mode from the default. Only server-to-server requests can enroll with other modes.

  • user: Optional. The user ID of the currently logged in user. You cannot use the command to enroll a different user.

GET Response Values

If an unspecified error occurs when the user tries to obtain a learner’s enrollments, the request returns an HTTP 400 “Bad Request” response.

If the user does not have permission to view enrollment data for the requested learner, the request returns an HTTP 404 “Not Found” response.

POST Response Values

If the user does not specify a course ID, the specified course does not exist, or the is_active status is invalid, the request returns an HTTP 400 “Bad Request” response.

If a user who is not an admin tries to upgrade a learner’s course mode, the request returns an HTTP 403 “Forbidden” response.

If the specified user does not exist, the request returns an HTTP 406 “Not Acceptable” response.

GET and POST Response Values

If the request is successful, an HTTP 200 “OK” response is returned along with a collection of course enrollments for the user or for the newly created enrollment.

Each course enrollment contains the following values.

  • course_details: A collection that includes the following values.

    • course_end: The date and time when the course closes. If null, the course never ends.

    • course_id: The unique identifier for the course.

    • course_modes: An array of data about the enrollment modes supported for the course. If the request uses the parameter include_expired=1, the array also includes expired enrollment modes.

      Each enrollment mode collection includes the following values.

      • currency: The currency of the listed prices.
      • description: A description of this mode.
      • expiration_datetime: The date and time after which users cannot enroll in the course in this mode.
      • min_price: The minimum price for which a user can enroll in this mode.
      • name: The full name of the enrollment mode.
      • slug: The short name for the enrollment mode.
      • suggested_prices: A list of suggested prices for this enrollment mode.
    • course_start: The date and time when the course opens. If null, the course opens immediately when it is created.

    • enrollment_end: The date and time after which users cannot enroll for the course. If null, the enrollment period never ends.

    • enrollment_start: The date and time when users can begin enrolling in the course. If null, enrollment opens immediately when the course is created.

    • invite_only: A value indicating whether students must be invited to enroll in the course. Possible values are true or false.

  • created: The date the user account was created.
  • is_active: Whether the enrollment is currently active.
  • mode: The enrollment mode of the user in this course.
  • user: The username of the user.

Example response showing a user who is enrolled in two courses

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS

[
    {
        "created": "2014-09-19T18:08:37Z",
        "mode": "honor",
        "is_active": true,
        "course_details": {
            "course_id": "edX/DemoX/Demo_Course",
            "enrollment_end": null,
            "course_modes": [
                {
                    "slug": "honor",
                    "name": "Honor Code Certificate",
                    "min_price": 0,
                    "suggested_prices": [],
                    "currency": "usd",
                    "expiration_datetime": null,
                    "description": null
                }
            ],
            "enrollment_start": null,
            "invite_only": false
        },
        "user": "honor"
    },
    {
        "created": "2014-09-19T18:09:35Z",
        "mode": "honor",
        "is_active": true,
        "course_details": {
            "course_id": "ArbisoftX/BulkyEmail101/2014-15",
            "enrollment_end": null,
            "course_modes": [
                {
                    "slug": "honor",
                    "name": "Honor Code Certificate",
                    "min_price": 0,
                    "suggested_prices": [],
                    "currency": "usd",
                    "expiration_datetime": null,
                    "description": null
                }
            ],
            "enrollment_start": "2014-05-01T04:00:00Z",
            "invite_only": false
        },
        "user": "honor"
    }
]

Example response showing that a user has been enrolled in a new course

{
    "course_details": {
        "course_id": "edX/DemoX/Demo_Course"
    }
}