lms.djangoapps.program_enrollments.rest_api.v1 package#
Submodules#
lms.djangoapps.program_enrollments.rest_api.v1.constants module#
Constants used throughout the program_enrollments V1 API.
lms.djangoapps.program_enrollments.rest_api.v1.serializers module#
API Serializers
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.CourseRunOverviewListSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for a list of course run overviews.
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.CourseRunOverviewSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for a course run overview.
- STATUS_CHOICES = ['in_progress', 'upcoming', 'completed']#
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.DueDateSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for a due date.
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.InvalidStatusMixin#
Bases:
objectMixin to provide has_invalid_status method
- has_invalid_status()#
Returns whether or not this serializer has an invalid error choice on the “status” field.
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseEnrollmentRequestSerializer(*args, **kwargs)#
Bases:
Serializer,InvalidStatusMixinSerializer for request to create a ProgramCourseEnrollment
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseEnrollmentSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for displaying program-course enrollments.
- class Meta#
Bases:
object- model#
alias of
ProgramCourseEnrollment
- get_account_exists(obj)#
- get_course_staff(obj)#
- get_curriculum_uuid(obj)#
- get_student_key(obj)#
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseGradeSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for a user’s grade in a program courserun.
Meant to be used with BaseProgramCourseGrade.
- get_student_key(obj)#
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentCreateRequestSerializer(*args, **kwargs)#
Bases:
ProgramEnrollmentRequestMixinSerializer for program enrollment creation requests.
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentRequestMixin(*args, **kwargs)#
Bases:
InvalidStatusMixin,SerializerBase fields for all program enrollment related serializers.
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for displaying enrollments in a program.
- class Meta#
Bases:
object- model#
alias of
ProgramEnrollment
- get_account_exists(obj)#
- get_email(obj)#
- get_username(obj)#
- class lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentUpdateRequestSerializer(*args, **kwargs)#
Bases:
ProgramEnrollmentRequestMixinSerializer for program enrollment update requests.
lms.djangoapps.program_enrollments.rest_api.v1.urls module#
Program Enrollments API v1 URLs.
lms.djangoapps.program_enrollments.rest_api.v1.utils module#
ProgramEnrollment V1 API internal utilities.
- class lms.djangoapps.program_enrollments.rest_api.v1.utils.ProgramCourseSpecificViewMixin#
Bases:
ProgramSpecificViewMixinA mixin for views that operate on or within a specific course run in a program
Requires course_id to be one of the kwargs to the view.
- course_key#
The course key for the course run specified by the course_id URL parameter.
- class lms.djangoapps.program_enrollments.rest_api.v1.utils.ProgramEnrollmentPagination#
Bases:
CursorPaginationPagination class for views in the Program Enrollments app.
- get_paginated_response(data, status_code=200, **kwargs)#
Return a response given serialized page data, optional status_code (defaults to 200), and kwargs. Each key-value pair of kwargs is added to the response data.
- ordering = 'id'#
- page_size = 100#
- page_size_query_param = 'page_size'#
- class lms.djangoapps.program_enrollments.rest_api.v1.utils.ProgramSpecificViewMixin#
Bases:
objectA mixin for views that operate on or within a specific program.
Requires program_uuid to be one of the kwargs to the view.
- program#
The program specified by the program_uuid URL parameter.
Returns: dict
- property program_uuid#
The program specified by the program_uuid URL parameter.
Returns: str
- class lms.djangoapps.program_enrollments.rest_api.v1.utils.UserProgramCourseEnrollmentPagination#
Bases:
CursorPaginationPagination parameters for UserProgramCourseEnrollmentView.
- max_page_size = 25#
- ordering = 'id'#
- page_size = 10#
- page_size_query_param = 'page_size'#
- class lms.djangoapps.program_enrollments.rest_api.v1.utils.UserProgramSpecificViewMixin#
Bases:
ProgramSpecificViewMixinA mixin for views that operate on a specific program in the context of a user.
Requires program_uuid to be one of the kwargs to the view.
The property target_user returns the user that that we should operate with.
- property target_user#
The user that this view’s operations should operate in the context of.
By default, this is the requesting user.
This can be overriden in order to implement “user-parameterized” views, which, for example, a global staff member could use to see API responses in the context of a specific learner. This could be used to help implement masquerading.
- lms.djangoapps.program_enrollments.rest_api.v1.utils.get_course_run_status(course_overview, certificate_info)#
Get the progress status of a course run, given the state of a user’s certificate in the course.
In the case of self-paced course runs, the run is considered completed when either the courserun has ended OR the user has earned a passing certificate 30 days ago or longer.
- Parameters:
course_overview (CourseOverview) – the overview for the course run
certificate_info – A dict containing the following keys:
is_passing: whether the user has a passing certificate in the course runcreated: the date the certificate was created
- Returns:
- one of (
CourseRunProgressStatuses.COMPLETE, CourseRunProgressStatuses.IN_PROGRESS, CourseRunProgressStatuses.UPCOMING,
)
- Return type:
- lms.djangoapps.program_enrollments.rest_api.v1.utils.get_enrollment_http_code(result_statuses, ok_statuses)#
Given a set of enrollment create/update statuses, return the appropriate HTTP status code.
- Parameters:
result_statuses (sequence[str]) – set of enrollment operation statuses (for example, ‘enrolled’, ‘not-in-program’, etc.)
ok_statuses – sequence[str]: set of ‘OK’ (non-error) statuses
- lms.djangoapps.program_enrollments.rest_api.v1.utils.get_enrollment_overviews(user, program, enrollments, request)#
Get a list of overviews for a user’s course run enrollments within a program.
- Parameters:
user (User)
program (dict)
enrollments (iterable[CourseEnrollment])
request (HttpRequest) – Source HTTP request. Needed for URL generation.
Returns list[dict]
- lms.djangoapps.program_enrollments.rest_api.v1.utils.get_enrollments_for_courses_in_program(user, program)#
Get a user’s active enrollments for course runs with the given program.
Note that this is distinct from the user’s program course enrollments, which refers to courses that were enrollmed in through a program.
In the case of this function, the course runs themselves must be part of the program, but the enrollments do not need to be associated with a program enrollment.
- Parameters:
user (User)
program (dict)
Returns QuerySet[CourseEnrollment]
- lms.djangoapps.program_enrollments.rest_api.v1.utils.get_single_enrollment_overview(user, program, course_overview, certificate_info, relative_resume_url, request)#
Get an overview of a user’s enrollment in a course run within a program.
- Parameters:
user (User)
program (Program)
course_overview (CourseOverview)
certificate_info (dict) – Info about a user’s certificate in this course run.
relative_resume_url (str) – URL to resume course. Relative to LMS root.
request (HttpRequest) – Source HTTP request. Needed for URL generation.
Returns: dict
- lms.djangoapps.program_enrollments.rest_api.v1.utils.verify_course_exists_and_in_program(view_func)#
- Raises:
An api error if the course run specified by the course_id kwarg –
in the wrapped function is not part of the curriculum of the program –
specified by the program_uuid kwarg –
This decorator guarantees existance of the program and course, so wrapping alongside verify_{program,course}_exists is redundant.
Expects to be used within a subclass of ProgramCourseSpecificViewMixin.
- lms.djangoapps.program_enrollments.rest_api.v1.utils.verify_program_exists(view_func)#
- Raises:
An API error if the program_uuid kwarg in the wrapped function –
does not exist in the catalog programs cache. –
Expects to be used within a ProgramSpecificViewMixin subclass.
- lms.djangoapps.program_enrollments.rest_api.v1.utils.verify_user_enrolled_in_program(view_func)#
Raised PermissionDenied if the target_user is not enrolled in the program.
Expects to be used within a UserProgramViewMixin subclass.
lms.djangoapps.program_enrollments.rest_api.v1.views module#
ProgramEnrollment Views
- class lms.djangoapps.program_enrollments.rest_api.v1.views.EnrollmentDataResetView(**kwargs)#
Bases:
APIViewResets enrollments and users for a given organization and set of programs. Note, this will remove ALL users from the input organization.
Path:
/api/program_enrollments/v1/integration-reset/Accepts: [POST]
POST#
- Returns
200: OK - Enrollments and users sucessfully deleted
400: Bad Requeset - Program does not match the requested organization
401: Unauthorized - The requesting user is not authenticated.
404: Not Found - A requested program does not exist.
Response
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- permission_classes = (<rest_framework.permissions.OperandHolder object>,)#
- post(request)#
Reset enrollment and user data for organization
- class lms.djangoapps.program_enrollments.rest_api.v1.views.EnrollmentWriteMixin#
Bases:
objectCommon functionality for viewsets with enrollment-writing POST/PATCH/PUT methods.
Provides a handle_write_request utility method, which depends on the definitions of serializer_class_by_write_method, ok_write_statuses, and perform_enrollment_write.
- create_update_by_write_method = {'PATCH': (False, True), 'POST': (True, False), 'PUT': (True, True)}#
- handle_write_request()#
Create/modify program enrollments. Returns: Response
- ok_write_statuses = 'set-me-to-a-set'#
- perform_enrollment_write(enrollment_requests, create, update)#
Perform the write operation. Implemented in subclasses.
- Parameters:
enrollment_requests – list[dict]
create (bool)
update (bool)
- Returns: dict[str: str]
Map from external keys to enrollment write statuses.
- serializer_class_by_write_method = 'set-me-to-a-dict-with-http-method-keys'#
- class lms.djangoapps.program_enrollments.rest_api.v1.views.ProgramCourseEnrollmentOverviewView(**kwargs)#
Bases:
DeveloperErrorViewMixin,UserProgramSpecificViewMixin,RetrieveAPIViewA view for getting data associated with a user’s course enrollments as part of a program enrollment.
Path:
/api/program_enrollments/v1/programs/{program_uuid}/overview/DEPRECATED: This is deprecated in favor of the new UserProgramCourseEnrollmentView, which is paginated. It will be removed in a follow-up to MST-126 after the Programs Learner Portal has been updated to use UserProgramCourseEnrollmentView.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get_object()#
Defines the GET endpoint for overviews of course enrollments for a user as part of a program.
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- serializer_class#
alias of
CourseRunOverviewListSerializer
- class lms.djangoapps.program_enrollments.rest_api.v1.views.ProgramCourseEnrollmentsView(**kwargs)#
Bases:
EnrollmentWriteMixin,DeveloperErrorViewMixin,ProgramCourseSpecificViewMixin,PaginatedAPIViewA view for enrolling students in a course through a program, modifying program course enrollments, and listing program course enrollments.
Path:
/api/program_enrollments/v1/programs/{program_uuid}/courses/{course_id}/enrollments/Accepts: [GET, POST, PATCH, PUT]
For GET requests, the path can contain an optional page_size?=N query parameter. The default page size is 100.
POST, PATCH, PUT#
Returns
200: Returns a map of students and their enrollment status.
207: Not all students enrolled. Returns resulting enrollment status.
401: User is not authenticated
403: User lacks read access organization of specified program.
404: Program does not exist, or course does not exist in program
422: Invalid request, unable to enroll students.
GET#
Returns
200: OK - Contains a paginated set of program course enrollment data.
401: The requesting user is not authenticated.
403: The requesting user lacks access for the given program/course.
404: The requested program or course does not exist.
Response
In the case of a 200 response code, the response will include a paginated data set. The results section of the response consists of a list of program course enrollment records, where each record contains the following keys:
student_key: The identifier of the student enrolled in the program and course.
status: The student’s course enrollment status.
account_exists: A boolean indicating if the student has created an edx-platform user account.
curriculum_uuid: The curriculum UUID of the enrollment record for the (student, program).
Example
- {
“next”: null, “previous”: “http://testserver.com/api/program_enrollments/v1/programs/
{program_uuid}/courses/{course_id}/enrollments/?curor=abcd”,
- “results”: [
- {
“student_key”: “user-0”, “status”: “inactive”, “account_exists”: False, “curriculum_uuid”: “00000000-1111-2222-3333-444444444444”
}, {
“student_key”: “user-1”, “status”: “inactive”, “account_exists”: False, “curriculum_uuid”: “00000001-1111-2222-3333-444444444444”
}, {
“student_key”: “user-2”, “status”: “active”, “account_exists”: True, “curriculum_uuid”: “00000002-1111-2222-3333-444444444444”
}, {
“student_key”: “user-3”, “status”: “active”, “account_exists”: True, “curriculum_uuid”: “00000003-1111-2222-3333-444444444444”
},
],
}
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get(request, program_uuid=None, course_id=None)#
Get a list of students enrolled in a course within a program.
- ok_write_statuses = ('active', 'inactive')#
- pagination_class#
alias of
ProgramEnrollmentPagination
- patch(request, program_uuid=None, course_id=None)#
Modify the program course enrollments of a list of learners
- perform_enrollment_write(enrollment_requests, create, update)#
Perform the program enrollment write operation. Overridden from EnrollmentWriteMixin.
- Parameters:
enrollment_requests – list[dict]
create (bool)
update (bool)
- Returns: dict[str: str]
Map from external keys to enrollment write statuses.
- permission_classes = (<rest_framework.permissions.OperandHolder object>,)#
- post(request, program_uuid=None, course_id=None)#
Enroll a list of students in a course in a program
- put(request, program_uuid=None, course_id=None)#
Create or Update the program course enrollments of a list of learners
- serializer_class_by_write_method = {'PATCH': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseEnrollmentRequestSerializer'>, 'POST': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseEnrollmentRequestSerializer'>, 'PUT': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramCourseEnrollmentRequestSerializer'>}#
- class lms.djangoapps.program_enrollments.rest_api.v1.views.ProgramCourseGradesView(**kwargs)#
Bases:
DeveloperErrorViewMixin,ProgramCourseSpecificViewMixin,PaginatedAPIViewA view for retrieving a paginated list of grades for all students enrolled in a given courserun through a given program.
Path:
/api/program_enrollments/v1/programs/{program_uuid}/courses/{course_id}/grades/Accepts: [GET]
For GET requests, the path can contain an optional page_size?=N query parameter. The default page size is 100.
GET#
- Returns
200: OK - Contains a paginated set of program courserun grades.
204: No Content - No grades to return
- 207: Mixed result - Contains mixed list of program courserun grades
and grade-fetching errors
422: All failed - Contains list of grade-fetching errors
401: The requesting user is not authenticated.
403: The requesting user lacks access for the given program/course.
404: The requested program or course does not exist.
Response
In the case of a 200/207/422 response code, the response will include a paginated data set. The results section of the response consists of a list of grade records, where each successfully loaded record contains:
student_key: The identifier of the student enrolled in the program and course.
letter_grade: A letter grade as defined in grading policy (e.g. ‘A’ ‘B’ ‘C’ for 6.002x) or None.
passed: Boolean representing whether the course has been passed according to the course’s grading policy.
percent: A float representing the overall grade for the course.
- and failed-to-load records contain:
student_key
error: error message from grades Exception
Example
207 Multi-Status {
“next”: null, “previous”: “http://example.com/api/program_enrollments/v1/programs/
{program_uuid}/courses/{course_id}/grades/?cursor=abcd”,
- “results”: [;
- {
“student_key”: “01709bffeae2807b6a7317”, “letter_grade”: “Pass”, “percent”: 0.95, “passed”: true
}, {
“student_key”: “2cfe15e3380a52e7198237”, “error”: “Timeout while calculating grade”
],
}
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get(request, program_uuid=None, course_id=None)#
Defines the GET list endpoint for ProgramCourseGrade objects.
- pagination_class#
alias of
ProgramEnrollmentPagination
- permission_classes = (<rest_framework.permissions.OperandHolder object>,)#
- class lms.djangoapps.program_enrollments.rest_api.v1.views.ProgramEnrollmentsView(**kwargs)#
Bases:
EnrollmentWriteMixin,DeveloperErrorViewMixin,ProgramSpecificViewMixin,PaginatedAPIViewA view for Create/Read/Update methods on Program Enrollment data.
Path: /api/program_enrollments/v1/programs/{program_uuid}/enrollments/ The path can contain an optional page_size?=N query parameter. The default page size is 100.
- Returns:
OK - Contains a paginated set of program enrollment data. * 401: The requesting user is not authenticated. * 403: The requesting user lacks access for the given program. * 404: The requested program does not exist.
- Return type:
200
Response: In the case of a 200 response code, the response will include a paginated data set. The results section of the response consists of a list of program enrollment records, where each record contains the following keys:
student_key: The identifier of the student enrolled in the program.
status: The student’s enrollment status.
account_exists: A boolean indicating if the student has created an edx-platform user account.
curriculum_uuid: The curriculum UUID of the enrollment record for the (student, program).
Example: {
“next”: null, “previous”: “http://testserver.com/api/program_enrollments/v1/programs/{program_uuid}/enrollments/?curor=abcd”, “results”: [
- {
“student_key”: “user-0”, “status”: “pending”, “account_exists”: False, “curriculum_uuid”: “00000000-1111-2222-3333-444444444444”
}, {
“student_key”: “user-1”, “status”: “pending”, “account_exists”: False, “curriculum_uuid”: “00000001-1111-2222-3333-444444444444”
}, {
“student_key”: “user-2”, “status”: “enrolled”, “account_exists”: True, “curriculum_uuid”: “00000002-1111-2222-3333-444444444444”
}, {
“student_key”: “user-3”, “status”: “enrolled”, “account_exists”: True, “curriculum_uuid”: “00000003-1111-2222-3333-444444444444”
},
],
}
Create#
Path: /api/program_enrollments/v1/programs/{program_uuid}/enrollments/ Where the program_uuid will be the uuid for a program.
- Request body:
- The request body will be a list of one or more students to enroll with the following schema:
- {
‘status’: A choice of the following statuses: [‘enrolled’, ‘pending’, ‘canceled’, ‘suspended’, ‘ended’], student_key: string representation of a learner in partner systems, ‘curriculum_uuid’: string representation of a curriculum
}
- Example:
- [
- {
“status”: “enrolled”, “external_user_key”: “123”, “curriculum_uuid”: “2d7de549-b09e-4e50-835d-4c5c5080c566”
- },{
“status”: “canceled”, “external_user_key”: “456”, “curriculum_uuid”: “2d7de549-b09e-4e50-835d-4c5c5080c566”
- },{
“status”: “pending”, “external_user_key”: “789”, “curriculum_uuid”: “2d7de549-b09e-4e50-835d-4c5c5080c566”
- },{
“status”: “suspended”, “external_user_key”: “abc”, “curriculum_uuid”: “2d7de549-b09e-4e50-835d-4c5c5080c566”
},
]
- returns:
- {<external_user_key>: <status>} with as many keys as there were in the request body
external_user_key - string representation of a learner in partner systems
- status - the learner’s registration status
- success statuses:
‘enrolled’
‘pending’
‘canceled’
‘suspended’
‘ended’
- failure statuses:
‘duplicated’ - the request body listed the same learner twice
‘conflict’ - there is an existing enrollment for that learner, curriculum and program combo
‘invalid-status’ - a status other than ‘enrolled’, ‘pending’, ‘canceled’, ‘suspended’, or ‘ended’ was entered
200: OK - All students were successfully enrolled. * Example json response:
- {
‘123’: ‘enrolled’, ‘456’: ‘pending’, ‘789’: ‘canceled, ‘abc’: ‘suspended’
}
207: MULTI-STATUS - Some students were successfully enrolled while others were not.
- Details are included in the JSON response data.
- Example json response:
- {
‘123’: ‘duplicated’, ‘456’: ‘conflict’, ‘789’: ‘invalid-status, ‘abc’: ‘suspended’
}
403: FORBIDDEN - The requesting user lacks access to enroll students in the given program.
404: NOT FOUND - The requested program does not exist.
413: PAYLOAD TOO LARGE - Over 25 students supplied
422: Unprocesable Entity - None of the students were successfully listed.
- rtype:
Response Body
Update#
Path: /api/program_enrollments/v1/programs/{program_uuid}/enrollments/ Where the program_uuid will be the uuid for a program.
- Request body:
- The request body will be a list of one or more students with their updated enrollment status:
- {
- ‘status’: A choice of the following statuses: [
‘enrolled’, ‘pending’, ‘canceled’, ‘suspended’, ‘ended’,
], student_key: string representation of a learner in partner systems
}
- Example:
- [
- {
“status”: “enrolled”, “external_user_key”: “123”,
- },{
“status”: “canceled”, “external_user_key”: “456”,
- },{
“status”: “pending”, “external_user_key”: “789”,
- },{
“status”: “suspended”, “external_user_key”: “abc”,
},
]
- returns:
- {<external_user_key>: <status>} with as many keys as there were in the request body
external_user_key - string representation of a learner in partner systems
- status - the learner’s registration status
- success statuses:
‘enrolled’
‘pending’
‘canceled’
‘suspended’
‘ended’
- failure statuses:
‘duplicated’ - the request body listed the same learner twice
‘conflict’ - there is an existing enrollment for that learner, curriculum and program combo
- ‘invalid-status’ - a status other than ‘enrolled’, ‘pending’, ‘canceled’, ‘suspended’, ‘ended’
was entered
‘not-in-program’ - the user is not in the program and cannot be updated
200: OK - All students were successfully enrolled. * Example json response:
- {
‘123’: ‘enrolled’, ‘456’: ‘pending’, ‘789’: ‘canceled, ‘abc’: ‘suspended’
}
207: MULTI-STATUS - Some students were successfully enrolled while others were not.
- Details are included in the JSON response data.
- Example json response:
- {
‘123’: ‘duplicated’, ‘456’: ‘not-in-program’, ‘789’: ‘invalid-status, ‘abc’: ‘suspended’
}
403: FORBIDDEN - The requesting user lacks access to enroll students in the given program.
404: NOT FOUND - The requested program does not exist.
413: PAYLOAD TOO LARGE - Over 25 students supplied
422: Unprocesable Entity - None of the students were successfully updated.
- rtype:
Response Body
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get(request, program_uuid=None)#
Defines the GET list endpoint for ProgramEnrollment objects.
- ok_write_statuses = ('enrolled', 'pending', 'suspended', 'canceled', 'ended')#
- pagination_class#
alias of
ProgramEnrollmentPagination
- patch(request, program_uuid=None)#
Update program enrollments for a list of learners
- perform_enrollment_write(enrollment_requests, create, update)#
Perform the program enrollment write operation. Overridden from EnrollmentWriteMixin.
- Parameters:
enrollment_requests – list[dict]
create (bool)
update (bool)
- Returns: dict[str: str]
Map from external keys to enrollment write statuses.
- permission_classes = (<rest_framework.permissions.OperandHolder object>,)#
- post(request, program_uuid=None)#
Create program enrollments for a list of learners
- put(request, program_uuid=None)#
Create/update program enrollments for a list of learners
- serializer_class_by_write_method = {'PATCH': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentUpdateRequestSerializer'>, 'POST': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentCreateRequestSerializer'>, 'PUT': <class 'lms.djangoapps.program_enrollments.rest_api.v1.serializers.ProgramEnrollmentCreateRequestSerializer'>}#
- class lms.djangoapps.program_enrollments.rest_api.v1.views.UserProgramCourseEnrollmentView(**kwargs)#
Bases:
DeveloperErrorViewMixin,UserProgramSpecificViewMixin,PaginatedAPIViewA view for getting data associated with a user’s course enrollments as part of a program enrollment.
For full documentation, see the program_enrollments section of http://$LMS_BASE_URL/api-docs/.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get(request, username, program_uuid)#
Get an overview of each of a user’s course enrollments associated with a program.
This endpoint exists to get an overview of each course-run enrollment that a user has for course-runs within a given program. Fields included are the title, upcoming due dates, etc. This API endpoint is intended for use with the [Program Learner Portal MFE](openedx/frontend-app-learner-portal-programs).
It is important to note that the set of enrollments that this endpoint returns is different than a user’s set of program-course-run enrollments. Specifically, this endpoint may include course runs that are within the specified program but were not enrolled in via the specified program.
“next”: null, “previous”: null, “results”: [
- {
“course_run_id”: “edX+AnimalsX+Aardvarks”, “display_name”: “Astonishing Aardvarks”, “course_run_url”: “https://courses.edx.org/courses/course-v1:edX+AnimalsX+Aardvarks/course/”, “start_date”: “2017-02-05T05:00:00Z”, “end_date”: “2018-02-05T05:00:00Z”, “course_run_status”: “completed” “emails_enabled”: true, “due_dates”: [
- {
“name”: “Introduction: What even is an aardvark?”, “url”: “https://courses.edx.org/courses/course-v1:edX+AnimalsX+Aardvarks/jump_to/
block-v1:edX+AnimalsX+Aardvarks+type@chapter+block@1414ffd5143b4b508f739b563ab468b7”,
“date”: “2017-05-01T05:00:00Z”
}, {
“name”: “Quiz: Aardvark or Anteater?”, “url”: “https://courses.edx.org/courses/course-v1:edX+AnimalsX+Aardvarks/jump_to/
block-v1:edX+AnimalsX+Aardvarks+type@sequential+block@edx_introduction”,
“date”: “2017-03-05T00:00:00Z”
}
], “micromasters_title”: “Animals”, “certificate_download_url”: “https://courses.edx.org/certificates/123”
}, {
“course_run_id”: “edX+AnimalsX+Baboons”, “display_name”: “Breathtaking Baboons”, “course_run_url”: “https://courses.edx.org/courses/course-v1:edX+AnimalsX+Baboons/course/”, “start_date”: “2018-02-05T05:00:00Z”, “end_date”: null, “course_run_status”: “in_progress” “emails_enabled”: false, “due_dates”: [], “micromasters_title”: “Animals”, “certificate_download_url”: “https://courses.edx.org/certificates/123”, “resume_course_run_url”: “https://courses.edx.org/courses/course-v1:edX+AnimalsX+Baboons/jump_to/
block-v1:edX+AnimalsX+Baboons+type@sequential+block@edx_introduction”
}
]
}#
- pagination_class#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- serializer_class#
alias of
CourseRunOverviewSerializer
- class lms.djangoapps.program_enrollments.rest_api.v1.views.UserProgramReadOnlyAccessView(**kwargs)#
Bases:
DeveloperErrorViewMixin,PaginatedAPIViewA view for checking the currently logged-in user’s program read only access There are three major categories of users this API is differentiating. See the table below.
| User Type | API Returns |#
edX staff | All programs || course staff | All programs containing the courses of which the user is course staff |#
learner | All programs the learner is enrolled in |
Path: /api/program_enrollments/v1/programs/enrollments/
- returns:
OK - Contains a list of all programs in which the user has read only acccess to. * 401: The requesting user is not authenticated.
- rtype:
200
- The list will be a list of objects with the following keys:
uuid - the identifier of the program in which the user has read only access to.
slug - the string from which a link to the corresponding program page can be constructed.
Example: [
- {
‘uuid’: ‘00000000-1111-2222-3333-444444444444’, ‘slug’: ‘deadbeef’
}, {
‘uuid’: ‘00000000-1111-2222-3333-444444444445’, ‘slug’: ‘undead-cattle’
}
]
- DEFAULT_PROGRAM_TYPE = 'masters'#
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- get(request)#
How to respond to a GET request to this endpoint
- get_course_keys_user_is_staff_for(user)#
Return all the course keys the user is course instructor or course staff role for
- get_programs_user_is_course_staff_for(user, program_type_filter)#
Return a list of programs the user is course staff for. This function would take a list of course runs the user is staff of, and then try to get the Masters program associated with each course_runs.
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#