openedx.features.course_experience package#

Subpackages#

Submodules#

openedx.features.course_experience.course_tools module#

Support for course tool plugins.

class openedx.features.course_experience.course_tools.CourseTool#

Bases: object

This is an optional base class for Course Tool plugins.

Plugin implementations inside this repo should subclass CourseTool to get useful default behavior, and to add clarity to the code. This base class is not a requirement, and plugin implementations outside of this repo should simply follow the contract defined below.

classmethod analytics_id()#

Returns an id to uniquely identify this tool in analytics events.

For example, ‘edx.bookmarks’. New tools may warrant doc updates for the new id.

classmethod data()#

Additional data to send with a form submission

http_method = 'GET'#
classmethod icon_classes(course_key)#

Returns the icon classes needed to represent this tool.

For example, return an icon from font-awasome.css, like ‘fa fa-star’.

classmethod is_enabled(request, course_key)#

Returns true if this tool is enabled for the specified course key.

classmethod title(course_key)#

Returns the title for the course tool.

classmethod url(course_key)#

Returns the URL for this tool for the specified course key.

class openedx.features.course_experience.course_tools.CourseToolsPluginManager#

Bases: PluginManager

Manager for all of the course tools that have been made available.

Course tool implementation can subclass CourseTool or can implement the required class methods themselves.

NAMESPACE = 'openedx.course_tool'#
classmethod get_course_tools()#

Returns the list of available course tools in their canonical order.

classmethod get_enabled_course_tools(request, course_key)#

Returns the course tools applicable to the current user and course.

class openedx.features.course_experience.course_tools.HttpMethod(*values)#

Bases: Enum

Enum for HTTP Methods

DELETE = 'DELETE'#
GET = 'GET'#
OPTIONS = 'OPTIONS'#
POST = 'POST'#
PUT = 'PUT'#

openedx.features.course_experience.course_updates module#

Utilities for course updates.

openedx.features.course_experience.course_updates.dismiss_current_update_for_user(request, course)#

Marks the current course update for this user as dismissed.

See get_current_update_for_user for what “current course update” means in practice.

openedx.features.course_experience.course_updates.get_current_update_for_user(request, course)#

Returns the current (most recent) course update HTML.

Some rules about when we show updates: - If the newest update has not been dismissed yet, it gets returned. - If the newest update has been dismissed, we will return None. - Will return a previously-dismissed newest update if it has been edited since being dismissed. - If a current update is deleted and an already dismissed update is now the newest one, we don’t want to show that.

openedx.features.course_experience.course_updates.get_ordered_updates(request, course)#

Returns all public course updates in reverse chronological order, including dismissed ones.

openedx.features.course_experience.plugins module#

Platform plugins to support the course experience.

This includes any locally defined CourseTools.

class openedx.features.course_experience.plugins.CourseUpdatesTool#

Bases: CourseTool

The course updates tool.

classmethod analytics_id()#

Returns an analytics id for this tool, used for eventing.

classmethod icon_classes()#

Returns icon classes needed to represent this tool.

classmethod is_enabled(request, course_key)#

Returns True if the user should be shown course updates for this course.

classmethod title()#

Returns the title of this tool.

classmethod url(course_key)#

Returns the URL for this tool for the specified course key.

openedx.features.course_experience.url_helpers module#

Helper functions for logic related to learning (courseare & course home) URLs.

Centralized in openedx/features/course_experience instead of lms/djangoapps/courseware because the Studio course outline may need these utilities.

openedx.features.course_experience.url_helpers.get_courseware_url(usage_key: UsageKey, request: HttpRequest | None = None, is_staff: bool = False) str#

Return the URL to the canonical learning experience for a given block.

We choose between either the Legacy frontend or Learning MFE depending on the course that the block is in, the requesting user, and the state of the ‘courseware’ waffle flags.

If redirecting to a specific Sequence or Sequence/Unit in a Learning MFE regardless of configuration, call make_learning_mfe_courseware_url directly for better performance.

Raises:
  • * ItemNotFoundError if no data at the usage_key.

  • * NoPathToItem if we cannot build a path to the usage_key.

openedx.features.course_experience.url_helpers.get_learning_mfe_home_url(course_key: CourseKey, url_fragment: str | None = None, params: QueryDict | None = None) str#

Given a course run key and view name, return the appropriate course home (MFE) URL.

We’re building a URL like this:

{LEARNING_MICROFRONTEND_URL}/course/course-v1:edX+DemoX+Demo_Course/dates

course_key can be either an OpaqueKey or a string. url_fragment is an optional string. params is an optional QueryDict object (e.g. request.GET)

openedx.features.course_experience.url_helpers.is_request_from_learning_mfe(request: HttpRequest)#

Returns whether the given request was made by the frontend-app-learning MFE.

openedx.features.course_experience.url_helpers.make_learning_mfe_courseware_url(course_key: CourseKey, sequence_key: UsageKey | None = None, unit_key: UsageKey | None = None, params: QueryDict | None = None, preview: bool = None) str#

Return a str with the URL for the specified courseware content in the Learning MFE.

The micro-frontend determines the user’s position in the vertical via a separate API call, so all we need here is the course_key, sequence, and vertical IDs to format it’s URL. For simplicity and performance reasons, this method does not inspect the modulestore to try to figure out what Unit/Vertical a sequence is in. If you try to pass in a unit_key without a sequence_key, the value will just be ignored and you’ll get a URL pointing to just the course_key.

Note that sequence_key may either point to a Section (ie chapter) or Subsection (ie sequential), as those are both abstractly understood as “sequences”. If you pass in a Section-level sequence_key, then the MFE will replace it with key of the first Subsection in that Section.

It is also capable of determining our section and vertical if they’re not present. Fully specifying it all is preferable, though, as the micro-frontend can save itself some work, resulting in a better user experience.

We’re building a URL like this:

{LEARNING_MICROFRONTEND_URL}/course/{course_id}/{sequence_id}/{veritcal_id}

course_key, sequence_key, and unit_key can be either OpaqueKeys or strings. They’re only ever used to concatenate a URL string. params is an optional QueryDict object (e.g. request.GET)

openedx.features.course_experience.urls module#

Defines URLs for the course experience.

openedx.features.course_experience.utils module#

Common utilities for the course experience, including course outline.

openedx.features.course_experience.utils.dates_banner_should_display(course_key, user, allow_warning=False)#

Return whether or not the reset banner should display, determined by whether or not a course has any past-due, incomplete sequentials and which enrollment mode is being dealt with for the current user and course.

Parameters:
  • course_key (CourseKey)

  • user (User)

  • allow_warning (bool) – whether to ignore relative_dates_disable_reset_flag, in order to render warnings for past-due incomplete units.

Returns:

missed_deadlines is True if the user has missed any graded content deadlines missed_gated_content is True if the first content that the user missed was gated content

Return type:

(missed_deadlines, missed_gated_content)

openedx.features.course_experience.utils.get_course_outline_block_tree(request, course_id, user=None, allow_start_dates_in_future=False)#

Returns the root block of the course outline, with children as blocks.

allow_start_dates_in_future (bool): When True, will allow blocks to be

returned that can bypass the StartDateTransformer’s filter to show blocks with start dates in the future.

openedx.features.course_experience.utils.get_start_block(block)#

Gets the deepest block to use as the starting block.

openedx.features.course_experience.utils.is_block_structure_complete_for_assignments(block_data, block_key)#

Considers a block complete only if all scored & graded leaf blocks are complete.

This is different from the normal complete flag because children of the block that are informative (like readings or videos) do not count. We only care about actual homework content.

openedx.features.course_experience.waffle module#

Miscellaneous waffle switches that both LMS and Studio need to access

Module contents#

Unified course experience settings and helper methods.

openedx.features.course_experience.course_home_page_title(_course)#

Returns the title for the course home page.

openedx.features.course_experience.course_home_url(course_key)#

Returns the course home page’s URL for the current user.

Parameters:

course_key (CourseKey) – The course key for which the home url is being requested.

openedx.features.course_experience.default_course_url(course_key)#

Returns the default course URL for the current user.

Parameters:

course_key (CourseKey) – The course id of the current course.