lms.djangoapps.mobile_api.course_info package#
Submodules#
lms.djangoapps.mobile_api.course_info.constants module#
Common constants for the course_info API.
lms.djangoapps.mobile_api.course_info.models module#
A models.py is required to make this an app (until we move to Django 1.7)
lms.djangoapps.mobile_api.course_info.serializers module#
Course Info serializers
- class lms.djangoapps.mobile_api.course_info.serializers.CourseAccessSerializer(*args, **kwargs)#
Bases:
SerializerGet info whether a user should be able to view course material.
- get_audit_access_expires(data: dict) str | None#
Returns expiration date for a course audit expiration, if any or null
- get_courseware_access(data: dict) dict#
Determine if the learner has access to the course, otherwise show error message.
- get_has_unmet_prerequisites(data: dict) bool#
Check whether or not a course has unmet prerequisites.
- get_is_staff(data: dict) bool#
Determine whether a user has staff access to this course.
- get_is_too_early(data: dict) bool#
Determine if the course is open to a learner (course has started or user has early beta access).
- class lms.djangoapps.mobile_api.course_info.serializers.CourseDetailSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for Course enrollment and overview details.
- static get_certificate(data)#
Returns course certificate url.
- get_course_access_details(data)#
Returns course access details.
- static get_course_handouts(data)#
Returns course_handouts.
- get_course_info_overview(data)#
Returns course info overview.
- static get_course_overview(course_id)#
Returns course overview.
- static get_course_updates(data)#
Returns course_updates.
- static get_discussion_url(data)#
Returns discussion url.
- static get_enrollment_details(data)#
Retrieve course enrollment details of the course.
- static get_id(data)#
Returns course id.
- class lms.djangoapps.mobile_api.course_info.serializers.CourseInfoOverviewSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer for additional course fields that should be returned in BlocksInfoInCourseView.
- class Meta#
Bases:
object- fields = ('name', 'number', 'org', 'org_logo', 'start', 'start_display', 'start_type', 'end', 'is_self_paced', 'media', 'course_sharing_utm_parameters', 'course_about', 'course_modes', 'course_progress')#
- model#
alias of
CourseOverview
- get_course_about_url(course_overview)#
- get_course_modes(course_overview)#
Retrieve course modes associated with the course.
- get_course_progress(obj: CourseOverview) Dict[str, int]#
Gets course progress calculated by course completed assignments.
- get_course_sharing_utm_parameters(obj)#
- static get_media(obj)#
Return course images in the correct format.
- get_org_logo(course_overview)#
- class lms.djangoapps.mobile_api.course_info.serializers.MobileCourseEnrollmentSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer for the CourseEnrollment object used in the BlocksInfoInCourseView.
lms.djangoapps.mobile_api.course_info.urls module#
URLs for course_info API
lms.djangoapps.mobile_api.course_info.utils module#
Common utility methods for Course info apis.
- lms.djangoapps.mobile_api.course_info.utils.get_user_certificate_download_url(request, user, course_id)#
Return the information about the user’s certificate in the course.
- Parameters:
request (Request) – The request object.
user (User) – The user object.
course_id (str) – The identifier of the course.
- Returns:
A dict containing information about location of the user’s certificate or an empty dictionary, if there is no certificate.
- Return type:
(dict)
lms.djangoapps.mobile_api.course_info.views module#
Views for course info API
- class lms.djangoapps.mobile_api.course_info.views.BlocksInfoInCourseView(**kwargs)#
Bases:
BlocksInCourseViewUse Case
This API endpoint is specifically optimized for the course homepage on Mobile Apps. The endpoint returns the blocks in the course according to the requesting user’s access level. Additionally, response encompasses info fields with information about the course, including certificate URL, media dictionary with course image URLs, start and end dates for the course.
Example requests:
This api works with all versions {api_version}, you can use: v0.5, v1, v2 or v3
GET /api/mobile/{api_version}/course_info/blocks/?course_id=<course_id> GET /api/mobile/{api_version}/course_info/blocks/?course_id=<course_id>
&username=anjali &depth=all &requested_fields=graded,format,student_view_multi_device,lti_url &block_counts=video &student_view_data=video &block_types_filter=problem,html
Parameters:
- username (str): The username of the specified user for whom the course data
is being accessed.
- depth (integer, str, None): Optional number of blocks you receive in response
course nesting depth, you can get only sections, sections and subsections, or provide string ‘all’ to receive all blocks of the course.
- requested_field (list): Optional list of names of additional fields to return for each block.
Supported fields can be found in transformers.SUPPORTED_FIELDS.
- block_counts (list): Optional list of names of block types for which an aggregated count
of blocks is returned.
- student_view_data (list): Optional list of names of block types for
which student_view_data is returned.
- block_types_filter (list): Filter by block types:
‘video’, ‘discussion’, ‘html’, ‘chapter’, ‘sequential’, ‘vertical’.
return_type (list, dict): Optional list or dictionary of block’s fields based on ‘return_type’.
Response example
Body consists of the following fields, you received this response if you use ‘return_type=dict’ in query params:
- root: (str) The ID of the root node of the requested course block structure. blocks: (dict) A dictionary or list, based on the value of the
“return_type” parameter. Maps block usage IDs to a collection of information about each block. Each block contains the following fields.
id: (str) The Course’s id (Course Run key) name: (str) The course’s name number: (str) The course’s number org: (str) The course’s organisation start: (str) Date the course begins, in ISO 8601 notation start_display: (str) Readably formatted start of the course start_type: (str) Hint describing how start_display is set. One of:
“string”: manually set by the course author
“timestamp”: generated from the start timestamp
“empty”: no start date is specified
end: (str) Date the course ends, in ISO 8601 notation media: (dict) An object that contains named media items. Included here:
course_image: An image to show for the course. Represented as an object with the following fields:
uri: The location of the image
- certificate: (dict) Information about the user’s earned certificate in the course.
- Included here:
uri: The location of the user’s certificate
is_self_paced: (bool) Indicates if the course is self paced
Body consists of the following fields, you received this response if you use ‘return_type=list’ in query params:
id: (str) The Course’s id (Course Run key) block_id: (str) The unique identifier for the block_id lms_web_url: (str) The URL to the navigational container of the xBlock on the web. legacy_web_url: (str) Like lms_web_url, but always directs to
the “Legacy” frontend experience.
- student_view_url: (str) The URL to retrieve the HTML rendering
of this block’s student view
- type: (str): The type of block. Possible values the names of any
XBlock type in the system, including custom blocks. Examples are course, chapter, sequential, vertical, html, problem, video, and discussion.
display_name: (str) The display name of the block. course_progress: (dict) Contains information about how many assignments are in the course
and how many assignments the student has completed. Included here:
total_assignments_count: (int) Total course’s assignments count.
assignments_completed: (int) Assignments witch the student has completed.
Returns
200 on success with above fields.
400 if an invalid parameter was sent or the username was not provided
401 unauthorized, the provided access token has expired and is no longer valid for an authenticated request.
403 if a user who does not have permission to masquerade as another user specifies a username other than their own.
404 if the course is not available or cannot be seen.
- 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_requested_user(user: User | AnonymousUser, username: str | None = None) User | AnonymousUser | None#
Return a user for whom the course blocks are fetched.
- Parameters:
user – current user from request.
username – string with username.
Returns: A user object or None.
- list(request, **kwargs)#
REST API endpoint for listing all the blocks information in the course and information about the course considering user access and roles.
- Parameters:
object (request - Django request)
- permission_classes = ()#
- class lms.djangoapps.mobile_api.course_info.views.CourseEnrollmentDetailsView(**kwargs)#
Bases:
APIViewAPI that returns course details for logged-in user in the given course
Example requests:
This api works with all versions {api_version}, you can use: v0.5, v1, v2 or v3
GET /api/mobile/{api_version}/course_info/{course_id}/enrollment_details
- 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, *args, **kwargs)#
Handle the GET request
Returns user enrollment and course details.
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- class lms.djangoapps.mobile_api.course_info.views.CourseGoalsRecordUserActivity(**kwargs)#
Bases:
APIViewAPI that allows the mobile_apps to record activity for course goals to the user activity table
- 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 = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- post(request, *args, **kwargs)#
Handle the POST request
Populate the user activity table.
- class lms.djangoapps.mobile_api.course_info.views.CourseHandoutsList(**kwargs)#
Bases:
ListAPIViewUse Case
Get the HTML for course handouts.
Example Request
GET /api/mobile/v0.5/course_info/{course_id}/handouts
Response Values
If the request is successful, the request returns an HTTP 200 “OK” response along with the following value.
handouts_html: The HTML for course handouts.
- 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'>)#
- list(request, course, *args, **kwargs)#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- class lms.djangoapps.mobile_api.course_info.views.CourseUpdatesList(**kwargs)#
Bases:
ListAPIViewUse Case
Get the content for course updates.
Example Request
GET /api/mobile/v0.5/course_info/{course_id}/updates
Response Values
If the request is successful, the request returns an HTTP 200 “OK” response along with an array of course updates. Each course update contains the following values.
content: The content, as an HTML string, of the course update.
date: The date of the course update.
id: The unique identifier of the update.
status: Whether the update is visible or not.
- 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'>)#
- list(request, course, *args, **kwargs)#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- lms.djangoapps.mobile_api.course_info.views.apply_wrappers_to_content(content, block, request)#
Updates a piece of html content with the filter functions stored in its module system, then replaces any static urls with absolute urls.
- Parameters:
content – The html content to which to apply the content wrappers generated for this module system.
block – The block containing a reference to the module system which contains functions to apply to the
include (content. These functions) –
Replacing static url’s
Replacing course url’s
Replacing jump to id url’s
request – The request, used to replace static URLs with absolute URLs.
Returns: A piece of html content containing the original content updated by each wrapper.
Module contents#
Course info API