lms.djangoapps.mobile_api.users package#
Submodules#
lms.djangoapps.mobile_api.users.serializers module#
Serializer for user API
- class lms.djangoapps.mobile_api.users.serializers.CourseEnrollmentSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializes CourseEnrollment models
- class Meta#
Bases:
object- fields = ('audit_access_expires', 'created', 'mode', 'is_active', 'course', 'certificate', 'course_modes')#
- lookup_field = 'username'#
- model#
alias of
CourseEnrollment
- get_audit_access_expires(model)#
Returns expiration date for a course audit expiration, if any or null
- get_certificate(model)#
Returns the information about the user’s certificate in the course.
- get_course_modes(obj)#
Retrieve course modes associated with the course.
- class lms.djangoapps.mobile_api.users.serializers.CourseEnrollmentSerializerv05(*args, **kwargs)#
Bases:
CourseEnrollmentSerializerSerializes CourseEnrollment models for v0.5 api Does not include ‘audit_access_expires’ field that is present in v1 api
- class lms.djangoapps.mobile_api.users.serializers.CourseOverviewField(*args, **kwargs)#
Bases:
RelatedFieldCustom field to wrap a CourseOverview object. Read-only.
- to_representation(course_overview)#
Transform the outgoing native value into primitive data.
- class lms.djangoapps.mobile_api.users.serializers.ModeSerializer(*args, **kwargs)#
Bases:
SerializerSerializes a course’s ‘Mode’ tuples
Returns a serialized representation of the modes available for course enrollment. The course modes models are designed to return a tuple instead of the model object itself. This serializer handles the given tuple.
- class lms.djangoapps.mobile_api.users.serializers.UserSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializes User models
- class Meta#
Bases:
object- fields = ('id', 'username', 'email', 'name', 'course_enrollments')#
- lookup_field = 'username'#
- ref_name = 'mobile_api.User'#
- get_course_enrollments(model)#
lms.djangoapps.mobile_api.users.urls module#
URLs for user API
lms.djangoapps.mobile_api.users.views module#
Views for user API
- class lms.djangoapps.mobile_api.users.views.UserCourseEnrollmentsList(**kwargs)#
Bases:
ListAPIViewUse Case
Get information about the courses that the currently signed in user is enrolled in.
v1 differs from v0.5 version by returning ALL enrollments for a user rather than only the enrollments the user has access to (that haven’t expired). An additional attribute “expiration” has been added to the response, which lists the date when access to the course will expire or null if it doesn’t expire.
Example Request
GET /api/mobile/v1/users/{username}/course_enrollments/
Response Values
If the request for information about the user is successful, the request returns an HTTP 200 “OK” response.
The HTTP 200 response has the following values.
expiration: The course expiration date for given user course pair or null if the course does not expire.
certificate: Information about the user’s earned certificate in the course.
course: A collection of the following data about the course.
courseware_access: A JSON representation with access information for the course, including any access errors.
course_about: The URL to the course about page.
course_sharing_utm_parameters: Encoded UTM parameters to be included in course sharing url
course_handouts: The URI to get data for course handouts.
course_image: The path to the course image.
course_updates: The URI to get data for course updates.
discussion_url: The URI to access data for course discussions if it is enabled, otherwise null.
end: The end date of the course.
id: The unique ID of the course.
name: The name of the course.
number: The course number.
org: The organization that created the course.
start: The date and time when the course starts.
start_display: If start_type is a string, then the advertised_start date for the course. If start_type is a timestamp, then a formatted date for the start of the course. If start_type is empty, then the value is None and it indicates that the course has not yet started.
start_type: One of either “string”, “timestamp”, or “empty”
subscription_id: A unique “clean” (alphanumeric with ‘_’) ID of the course.
video_outline: The URI to get the list of all videos that the user can access in the course.
created: The date the course was created.
is_active: Whether the course is currently active. Possible values are true or false.
mode: The type of certificate registration for this course (honor or certified).
url: URL to the downloadable version of the certificate, if exists.
- 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_queryset()#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- get_serializer_class()#
Return the class to use for the serializer. Defaults to using self.serializer_class.
You may want to override this if you need to provide different serializations depending on the incoming request.
(Eg. admins get full serialization, others get basic serialization)
- get_serializer_context()#
Extra context provided to the serializer class.
- is_org(check_org, course_org)#
Check course org matches request org param or no param provided
- list(request, *args, **kwargs)#
- lookup_field = 'username'#
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.IsUserInUrl'>)#
- queryset#
- class lms.djangoapps.mobile_api.users.views.UserCourseStatus(**kwargs)#
Bases:
APIViewUse Cases
Get or update the ID of the module that the specified user last visited in the specified course.
Get ID of the last completed block in case of version v1
Example Requests
GET /api/mobile/{version}/users/{username}/course_status_info/{course_id}
PATCH /api/mobile/{version}/users/{username}/course_status_info/{course_id}
PATCH Parameters
The body of the PATCH request can include the following parameters.
last_visited_module_id={module_id}
modification_date={date}
The modification_date parameter is optional. If it is present, the update will only take effect if the modification_date in the request is later than the modification_date saved on the server.
Response Values
If the request is successful, the request returns an HTTP 200 “OK” response.
The HTTP 200 response has the following values.
last_visited_module_id: The ID of the last module that the user visited in the course.
last_visited_module_path: The ID of the modules in the path from the last visited module to the course block.
For version v1 GET request response includes the following values.
last_visited_block_id: ID of the last completed block.
- 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'>)#
- dispatch(request, *args, **kwargs)#
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- get(request, course, *args, **kwargs)#
Get the ID of the module that the specified user last visited in the specified course.
- http_method_names = ['get', 'patch']#
- patch(request, course, *args, **kwargs)#
Update the ID of the module that the specified user last visited in the specified course.
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.IsUserInUrl'>)#
- class lms.djangoapps.mobile_api.users.views.UserDetail(**kwargs)#
Bases:
RetrieveAPIViewUse Case
Get information about the specified user and access other resources the user has permissions for.
Users are redirected to this endpoint after they sign in.
You can use the course_enrollments value in the response to get a list of courses the user is enrolled in.
Example Request
GET /api/mobile/{version}/users/{username}
Response Values
If the request is successful, the request returns an HTTP 200 “OK” response.
The HTTP 200 response has the following values.
course_enrollments: The URI to list the courses the currently signed in user is enrolled in.
email: The email address of the currently signed in user.
id: The ID of the user.
name: The full name of the currently signed in user.
username: The username of the currently signed in user.
- 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_serializer_context()#
Extra context provided to the serializer class.
- lookup_field = 'username'#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.IsUserInUrl'>)#
- queryset#
- serializer_class#
alias of
UserSerializer
- lms.djangoapps.mobile_api.users.views.my_user_info(request, *args, **kwargs)#
Redirect to the currently-logged-in user’s info page
Module contents#
User API