lms.djangoapps.ccx.api.v0 package#
Submodules#
lms.djangoapps.ccx.api.v0.paginators module#
CCX API v0 Paginators.
lms.djangoapps.ccx.api.v0.serializers module#
CCX API v0 Serializers.
- class lms.djangoapps.ccx.api.v0.serializers.CCXCourseSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer for CCX courses
- class Meta#
Bases:
object- fields = ('ccx_course_id', 'master_course_id', 'display_name', 'coach_email', 'start', 'due', 'max_students_allowed', 'course_modules')#
- model#
alias of
CustomCourseForEdX
- read_only_fields = ('ccx_course_id', 'master_course_id', 'start', 'due')#
- static get_ccx_course_id(obj)#
Getter for the CCX Course ID
- static get_course_modules(obj)#
Getter for the Course Blocks. The list is stored in a compressed field.
lms.djangoapps.ccx.api.v0.urls module#
CCX API v0 URLs.
lms.djangoapps.ccx.api.v0.views module#
API v0 views.
- class lms.djangoapps.ccx.api.v0.views.CCXDetailView(**kwargs)#
Bases:
GenericAPIViewUse Case
Get the details of CCX course.
Modify a CCX course.
Delete a CCX course.
Example Request
GET /api/ccx/v0/ccx/{ccx_course_id}
PATCH /api/ccx/v0/ccx/{ccx_course_id} {
“display_name”: “CCX example title modified”, “coach_email”: “joe@example.com”, “max_students_allowed”: 111, “course_modules” : [
“block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week1”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week4”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week5”
]
}
DELETE /api/ccx/v0/ccx/{ccx_course_id}
GET and DELETE Parameters
A GET or DELETE request must include the following parameter.
ccx_course_id: A string representation of a CCX Course ID.
PATCH Parameters
A PATCH request can include the following parameters
ccx_course_id: A string representation of a CCX Course ID.
display_name: Optional. A string representing the CCX Course title.
coach_email: Optional. A string representing the CCX owner email.
max_students_allowed: Optional. An integer representing he maximum number of students that can be enrolled in the CCX Course.
course_modules: Optional. A list of course modules id keys.
GET Response Values
If the request for information about the CCX course is successful, an HTTP 200 “OK” response is returned.
The HTTP 200 response has the following values.
ccx_course_id: A string representation of a CCX Course ID.
display_name: A string representing the CCX Course title.
coach_email: A string representing the CCX owner email.
start: A string representing the start date for the CCX Course.
due: A string representing the due date for the CCX Course.
max_students_allowed: An integer representing he maximum number of students that can be enrolled in the CCX Course.
course_modules: A list of course modules id keys.
PATCH and DELETE Response Values
If the request for modification or deletion of a CCX course is successful, an HTTP 204 “No Content” response is returned.
- 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'>)#
- delete(request, ccx_course_id=None)#
Deletes a CCX course.
- Parameters:
request (Request) – Django request object.
ccx_course_id (string) – URI element specifying the CCX course location.
- get(request, ccx_course_id=None)#
Gets a CCX Course information.
- Parameters:
request (Request) – Django request object.
ccx_course_id (string) – URI element specifying the CCX course location.
- Returns:
A JSON serialized representation of the CCX course.
- get_object(course_id, is_ccx=False)#
Override the default get_object to allow a custom getter for the CCX
- patch(request, ccx_course_id=None)#
Modifies a CCX course.
- Parameters:
request (Request) – Django request object.
ccx_course_id (string) – URI element specifying the CCX course location.
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'openedx.core.lib.api.permissions.IsCourseStaffInstructor'>)#
- serializer_class#
alias of
CCXCourseSerializer
- class lms.djangoapps.ccx.api.v0.views.CCXListView(**kwargs)#
Bases:
GenericAPIViewUse Case
Get the list of CCX courses for a given master course.
Creates a new CCX course for a given master course.
Example Request
GET /api/ccx/v0/ccx/?master_course_id={master_course_id}
POST /api/ccx/v0/ccx {
“master_course_id”: “course-v1:Organization+EX101+RUN-FALL2099”, “display_name”: “CCX example title”, “coach_email”: “john@example.com”, “max_students_allowed”: 123, “course_modules” : [
“block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week1”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week4”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week5”
]
}
GET Parameters
A GET request can include the following parameters.
master_course_id: A string representation of a Master Course ID. Note that this must be properly encoded by the client.
page: Optional. An integer representing the pagination instance number.
order_by: Optional. A string representing the field by which sort the results.
sort_order: Optional. A string (either “asc” or “desc”) indicating the desired order.
POST Parameters
A POST request can include the following parameters.
master_course_id: A string representation of a Master Course ID.
display_name: A string representing the CCX Course title.
coach_email: A string representing the CCX owner email.
max_students_allowed: An integer representing he maximum number of students that can be enrolled in the CCX Course.
course_modules: Optional. A list of course modules id keys.
GET Response Values
If the request for information about the course is successful, an HTTP 200 “OK” response is returned with a collection of CCX courses for the specified master course.
The HTTP 200 response has the following values.
results: a collection of CCX courses. Each CCX course contains the following values:
ccx_course_id: A string representation of a CCX Course ID.
display_name: A string representing the CCX Course title.
coach_email: A string representing the CCX owner email.
start: A string representing the start date for the CCX Course.
due: A string representing the due date for the CCX Course.
max_students_allowed: An integer representing he maximum number of students that can be enrolled in the CCX Course.
course_modules: A list of course modules id keys.
count: An integer representing the total number of records that matched the request parameters.
next: A string representing the URL where to retrieve the next page of results. This can be null in case the response contains the complete list of results.
previous: A string representing the URL where to retrieve the previous page of results. This can be null in case the response contains the first page of results.
Example GET Response
- {
“count”: 99, “next”: “https://openedx-ccx-api-instance.org/api/ccx/v0/ccx/?course_id=<course_id>&page=2”, “previous”: null, “results”: {
- {
“ccx_course_id”: “ccx-v1:Organization+EX101+RUN-FALL2099+ccx@1”, “display_name”: “CCX example title”, “coach_email”: “john@example.com”, “start”: “2019-01-01”, “due”: “2019-06-01”, “max_students_allowed”: 123, “course_modules” : [
“block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week1”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week4”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week5”
]
}, { … }
}
}
POST Response Values
If the request for the creation of a CCX Course is successful, an HTTP 201 “Created” response is returned with the newly created CCX details.
The HTTP 201 response has the following values.
ccx_course_id: A string representation of a CCX Course ID.
display_name: A string representing the CCX Course title.
coach_email: A string representing the CCX owner email.
start: A string representing the start date for the CCX Course.
due: A string representing the due date for the CCX Course.
max_students_allowed: An integer representing he maximum number of students that can be enrolled in the CCX Course.
course_modules: A list of course modules id keys.
Example POST Response
- {
“ccx_course_id”: “ccx-v1:Organization+EX101+RUN-FALL2099+ccx@1”, “display_name”: “CCX example title”, “coach_email”: “john@example.com”, “start”: “2019-01-01”, “due”: “2019-06-01”, “max_students_allowed”: 123, “course_modules” : [
“block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week1”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week4”, “block-v1:Organization+EX101+RUN-FALL2099+type@chapter+block@week5”
]
}
- 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)#
Gets a list of CCX Courses for a given Master Course.
Additional parameters are allowed for pagination purposes.
- Parameters:
request (Request) – Django request object.
- Returns:
A JSON serialized representation of a list of CCX courses.
- pagination_class#
alias of
CCXAPIPagination
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'openedx.core.lib.api.permissions.IsMasterCourseStaffInstructor'>)#
- post(request)#
Creates a new CCX course for a given Master Course.
- Parameters:
request (Request) – Django request object.
- Returns:
A JSON serialized representation a newly created CCX course.
- serializer_class#
alias of
CCXCourseSerializer
- lms.djangoapps.ccx.api.v0.views.TODAY()#
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
- lms.djangoapps.ccx.api.v0.views.get_valid_course(course_id, is_ccx=False, advanced_course_check=False)#
Helper function used to validate and get a course from a course_id string. It works with both master and ccx course id.
- Parameters:
course_id (str) – A string representation of a Master or CCX Course ID.
is_ccx (bool) – Flag to perform the right validation
advanced_course_check (bool) – Flag to perform extra validations for the master course
- Returns:
a tuple of course_object, course_key, error_code, http_status_code
- Return type:
tuple
- lms.djangoapps.ccx.api.v0.views.get_valid_input(request_data, ignore_missing=False)#
Helper function to validate the data sent as input and to build field based errors.
- Parameters:
request_data (OrderedDict) – the request data object
ignore_missing (bool) – whether or not to ignore fields missing from the input data
- Returns:
a tuple of two dictionaries for valid input and field errors
- Return type:
tuple
- lms.djangoapps.ccx.api.v0.views.make_user_coach(user, master_course_key)#
Makes an user coach on the master course. This function is needed because an user cannot become a coach of the CCX if s/he is not coach on the master course.
- Parameters:
user (User) – User object
master_course_key (CourseKey) – Key locator object for the course
- lms.djangoapps.ccx.api.v0.views.valid_course_modules(course_module_list, master_course_key)#
Function to validate that each element in the course_module_list belongs to the master course structure. :param course_module_list: A list of strings representing Block Usage Keys :type course_module_list: list :param master_course_key: An object representing the master course key id :type master_course_key: CourseKey
- Returns:
whether or not all the course module strings belong to the master course
- Return type:
bool