lms.djangoapps.course_home_api.outline package

Contents

lms.djangoapps.course_home_api.outline package#

Subpackages#

Submodules#

lms.djangoapps.course_home_api.outline.serializers module#

Outline Tab Serializers.

class lms.djangoapps.course_home_api.outline.serializers.CourseBlockSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Course Block Objects

get_blocks(block)#
static get_vertical_icon_class(block)#

Get the icon class for a vertical block based priority of child blocks types. Currently, the priority for the icon is as follows:

problem video

class lms.djangoapps.course_home_api.outline.serializers.CourseGoalsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Course Goal data

class lms.djangoapps.course_home_api.outline.serializers.CourseToolSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Course Tool Objects

get_url(tool)#
class lms.djangoapps.course_home_api.outline.serializers.DatesWidgetSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Dates Widget data

class lms.djangoapps.course_home_api.outline.serializers.EnrollAlertSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for enroll alert information

class lms.djangoapps.course_home_api.outline.serializers.OutlineTabCourseAccessRedirectSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a Course Access Redirect response from the outline tab

class lms.djangoapps.course_home_api.outline.serializers.OutlineTabSerializer(*args, **kwargs)#

Bases: DatesBannerSerializer, VerifiedModeSerializer

Serializer for the Outline Tab

class lms.djangoapps.course_home_api.outline.serializers.ResumeCourseSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for resume course data

lms.djangoapps.course_home_api.outline.views module#

Outline Tab Views

class lms.djangoapps.course_home_api.outline.views.CourseNavigationBlocksView(**kwargs)#

Bases: RetrieveAPIView

Use Cases

Request details for the sidebar navigation of the course.

Example Requests

GET api/course_home/v1/navigation/{course_key}

Response Values

For a good 200 response, the response will include: blocks: List of serialized Course Block objects. Each serialization has the following fields:

id: (str) The usage ID of the block. 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. lms_web_url: (str) The URL to the navigational container of the

xBlock on the web LMS.

children: (list) If the block has child blocks, a list of IDs of

the child blocks.

resume_block: (bool) Whether the block is the resume block has_scheduled_content: (bool) Whether the block has more content scheduled for the future

Returns
  • 200 on success.

  • 403 if the user does not currently have access to the course and should be redirected.

  • 404 if the course is not available or cannot be seen.

COURSE_BLOCKS_CACHE_KEY_TEMPLATE = 'course_sidebar_blocks_{course_key_string}_{course_version}_{user_id}_{user_cohort_id}_{enrollment_mode}_{allow_public}_{allow_public_outline}_{is_masquerading}'#
COURSE_BLOCKS_CACHE_TIMEOUT = 3600#
property aggregator_block_types: set[str]#

Return a set of block types that belong to XBlockCompletionMode.AGGREGATOR.

We use this information to determine if the block completion should depend on the completion of its children: 1. If the block is an aggregator, it should be marked as completed when all its children are completed. 2. If the block is completable, it should be directly marked as completed - regardless of its children.

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'>)#
property completable_block_types#

Returns a set of block types that can be marked as completed.

In addition to the lower-level x-blocks, it also includes blocks that belong to XBlockCompletionMode.AGGREGATOR, because they can also be marked as complete.

property completions_dict#

Return a dictionary of block completions for the current user.

Dictionary keys are block keys and values are int values representing the completion status of the block.

filter_inaccessible_blocks(course_blocks, course_key)#

Filter out sections and subsections that are not accessible to the current user.

get(request, *args, **kwargs)#

Get the visible course blocks (from course to vertical types) for the given course.

static get_accessible_sections(user_course_outline, course_sections)#

Filter out sections that are not accessible to the user.

static get_accessible_sequences(user_course_outline, course_sequences)#

Filter out sequences that are not accessible to the user.

get_block_completion_stat(block, completable_children)#

Get the completion status of a block.

Returns dictionary with the completion status and the number of completable children of a block. Completion is the value from 0 to 1 meaning the percentage of completion for lower-level blocks, and sum of the completion status of the completable children.

get_completable_children(block)#

Get the completable children of a block.

mark_complete_recursive(block)#

Mark blocks as complete or not complete based on the completions_dict.

serializer_class#

alias of CourseBlockSerializer

class lms.djangoapps.course_home_api.outline.views.OutlineTabView(**kwargs)#

Bases: RetrieveAPIView

Use Cases

Request details for the Outline Tab

Example Requests

GET api/course_home/v1/outline/{course_key}

Response Values

Body consists of two possible shapes.

For a good 200 response, the response will include:

access_expiration: An object detailing when access to this course will expire

expiration_date: (str) When the access expires, in ISO 8601 notation masquerading_expired_course: (bool) Whether this course is expired for the masqueraded user upgrade_deadline: (str) Last chance to upgrade, in ISO 8601 notation (or None if can’t upgrade anymore) upgrade_url: (str) Upgrade link (or None if can’t upgrade anymore)

course_blocks:
blocks: List of serialized Course Block objects. Each serialization has the following fields:

id: (str) The usage ID of the block. 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. lms_web_url: (str) The URL to the navigational container of the

xBlock on the web LMS.

children: (list) If the block has child blocks, a list of IDs of

the child blocks.

resume_block: (bool) Whether the block is the resume block has_scheduled_content: (bool) Whether the block has more content scheduled for the future

course_goals:
selected_goal:

days_per_week: (int) The number of days the learner wants to learn per week subscribed_to_reminders: (bool) Whether the learner wants email reminders about their goal

weekly_learning_goal_enabled: Flag indicating if this feature is enabled for this call

course_tools: List of serialized Course Tool objects. Each serialization has the following fields:

analytics_id: (str) The unique id given to the tool. title: (str) The display title of the tool. url: (str) The link to access the tool.

dates_banner_info: (obj)

content_type_gating_enabled: (bool) Whether content type gating is enabled for this enrollment. missed_deadlines: (bool) Whether the user has missed any graded content deadlines for the given course. missed_gated_content: (bool) Whether the user has missed any gated content for the given course. verified_upgrade_link: (str) The URL to ecommerce IDA for purchasing the verified upgrade.

dates_widget:
course_date_blocks: List of serialized Course Dates objects. Each serialization has the following fields:

complete: (bool) Meant to only be used by assignments. Indicates completeness for an assignment. date: (datetime) The date time corresponding for the event date_type: (str) The type of date (ex. course-start-date, assignment-due-date, etc.) description: (str) The description for the date event learner_has_access: (bool) Indicates if the learner has access to the date event link: (str) An absolute link to content related to the date event

(ex. verified link or link to assignment)

title: (str) The title of the date event

dates_tab_link: (str) The URL to the Dates Tab user_timezone: (str) The timezone of the given user

enroll_alert:

can_enroll: (bool) Whether the user can enroll in the given course extra_text: (str)

enrollment_mode: (str) Current enrollment mode. Null if the user is not enrolled. handouts_html: (str) Raw HTML for the handouts section of the course info has_ended: (bool) Indicates whether course has ended offer: An object detailing upgrade discount information

code: (str) Checkout code expiration_date: (str) Expiration of offer, in ISO 8601 notation original_price: (str) Full upgrade price without checkout code; includes currency symbol discounted_price: (str) Upgrade price with checkout code; includes currency symbol percentage: (int) Amount of discount upgrade_url: (str) Checkout URL

resume_course:

has_visited_course: (bool) Whether the user has ever visited the course url: (str) The display name of the course block to resume

welcome_message_html: (str) Raw HTML for the course updates banner user_has_passing_grade: (bool) Whether the user currently is passing the course

If the learner does not have access to the course for a specific reason and should be redirected this view will return a 403 and the following data:

url: (str) The URL to which the user should be redirected error_code: (str) A system identifier for the reason the user is being redirected developer_message: (str) A message explaining why the user is being redirected,

intended for developer debugging.

user_message: (str) A message explaining why the user is being redirected, intended to be shown to the user.

Returns

  • 200 on success.

  • 403 if the user does not currently have access to the course and should be redirected.

  • 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'>)#
finalize_response(request, response, *args, **kwargs)#

Return the final response, exposing the ‘Date’ header for computing relative time to the dates in the data.

Important dates such as ‘access_expiration’ are enforced server-side based on correct time; client-side clocks are frequently substantially far off which could lead to inaccurate messaging and incorrect expectations. Therefore, any messaging about those dates should be based on the server time and preferably in relative terms (time remaining); the ‘Date’ header is a straightforward and generalizable way for client-side code to get this reference.

get(request, *args, **kwargs)#
serializer_class#

alias of OutlineTabSerializer

exception lms.djangoapps.course_home_api.outline.views.UnableToDismissWelcomeMessage(detail=None, code=None)#

Bases: APIException

default_code = 'unable_to_dismiss_welcome_message'#
default_detail = 'Unable to dismiss welcome message.'#
status_code = 400#
exception lms.djangoapps.course_home_api.outline.views.UnableToSaveCourseGoal(detail=None, code=None)#

Bases: APIException

default_code = 'unable_to_save_course_goal'#
default_detail = 'Unable to save course goal'#
status_code = 400#
lms.djangoapps.course_home_api.outline.views.dismiss_welcome_message(request, *args, **kwargs)#
lms.djangoapps.course_home_api.outline.views.save_course_goal(request, *args, **kwargs)#
lms.djangoapps.course_home_api.outline.views.unsubscribe_from_course_goal_by_token(request, *args, **kwargs)#

API calls to unsubscribe from course goal reminders.

Note that this does not require authentication - this view may be hit from an email on a different device than normal or whatever. We should still be able to unsubscribe the user. Instead, we use a token in the email to validate that they have permission to unsubscribe.

This endpoint is very tightly scoped (only unsubscribe: no subscribing, no PII) because it is unauthenticated.

Example Requests

POST api/course_home/v1/unsubscribe_from_course_goal/{token}

Example Response Data

{‘course_title’: ‘Cats & Dogs In Canadian Media’}

Returns a 404 response if the token was not found. Otherwise, returns some basic course info. But no PII.

Module contents#