openedx.core.djangoapps.content.learning_sequences.api.processors package

Contents

openedx.core.djangoapps.content.learning_sequences.api.processors package#

Submodules#

openedx.core.djangoapps.content.learning_sequences.api.processors.base module#

This module defines the base OutlineProcessor class that is the primary method of adding new logic that manipulates the Course Outline for a given student.

class openedx.core.djangoapps.content.learning_sequences.api.processors.base.OutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: object

Base class for manipulating the Course Outline.

You can inherit from this class and extend any of its four main methods: __init__, load_data, inaccessible_sequences, usage_keys_to_remove.

An OutlineProcessor is invoked synchronously during a request for the CourseOutline. The steps are:

  • __init__

  • load_data

  • inaccessible_sequences, usage_keys_to_remove (no ordering guarantee)

Also note that you should not assume any ordering relative to any other OutlineProcessor. Once async support works its way fully into Django, we’ll likely even want to run these in parallel.

Some outline processors (like ScheduleOutlineProcessor) may choose to have additional methods to return specific metadata to feed into UserCourseOutlineDetailsData.

inaccessible_sequences(full_course_outline: CourseOutlineData)#

Return a set/frozenset of Sequence UsageKeys that are not accessible.

This will not be run for staff users (who can access everything), so there is no need to check for staff access here.

load_data(full_course_outline: CourseOutlineData)#

Fetch whatever data you need about the course and user here.

If everything you need is already in the CourseOutlineData, there is no need to override this method.

DO NOT USE MODULESTORE OR BLOCKSTRUCTURES HERE, as the up-front performance penalties of those modules are the entire reason this app exists. Running this method in your subclass should take no more than tens of milliseconds, even on courses with hundreds of learning sequences.

usage_keys_to_remove(full_course_outline: CourseOutlineData)#

Return a set/frozenset of UsageKeys to remove altogether.

This will not be run for staff users (who can see everything), so there is no need to check for staff access here.

openedx.core.djangoapps.content.learning_sequences.api.processors.cohort_partition_groups module#

class openedx.core.djangoapps.content.learning_sequences.api.processors.cohort_partition_groups.CohortPartitionGroupsOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Processor for applying cohort user partition groups.

load_data(full_course_outline) None#

Load the cohorted partition id and the user’s group id.

usage_keys_to_remove(full_course_outline)#

Content group exclusions remove the content entirely.

Remove sections and sequences inacessible by the user’s cohort.

openedx.core.djangoapps.content.learning_sequences.api.processors.content_gating module#

class openedx.core.djangoapps.content.learning_sequences.api.processors.content_gating.ContentGatingOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Responsible for applying all content gating outline processing.

This includes: - Entrance Exams - Chapter gated content

gated_by_required_content(section_usage_key)#

Returns True if the current section associated with the usage_key should be gated by the given required_content. Returns False otherwise.

inaccessible_sequences(full_course_outline)#

Mark any section that is gated by required content as inaccessible

load_data(full_course_outline)#

Get the required content for the course, and whether or not the user can skip the entrance exam.

openedx.core.djangoapps.content.learning_sequences.api.processors.enrollment module#

Simple OutlineProcessor that removes items based on Enrollment and course visibility setting.

class openedx.core.djangoapps.content.learning_sequences.api.processors.enrollment.EnrollmentOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Simple OutlineProcessor that removes items based on Enrollment and course visibility setting.

inaccessible_sequences(full_course_outline)#

Return a set/frozenset of Sequence UsageKeys that are not accessible.

usage_keys_to_remove(full_course_outline)#

Return sequences/sections to be removed

openedx.core.djangoapps.content.learning_sequences.api.processors.enrollment_track_partition_groups module#

class openedx.core.djangoapps.content.learning_sequences.api.processors.enrollment_track_partition_groups.EnrollmentTrackPartitionGroupsOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Processor for applying all enrollment track user partition groups.

Confining the processor to only EnrollmentTrack user partition is a significant limitation. Nonetheless, it is a step towards the goal of supporting all partition schemes in the future.

load_data(full_course_outline) None#

Pull track groups for this course and which group the user is in.

usage_keys_to_remove(full_course_outline)#

Content group exclusions remove the content entirely.

If you’re in the Audit track, there are things in the Verified track that you don’t even know exists. This processor always removes things entirely instead of making them visible-but-inaccessible (like ScheduleOutlineProcessor does).

openedx.core.djangoapps.content.learning_sequences.api.processors.milestones module#

class openedx.core.djangoapps.content.learning_sequences.api.processors.milestones.MilestonesOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Responsible for applying all general course milestones outline processing.

This does not include Entrance Exams (see ContentGatingOutlineProcessor), or Special Exams (see SpecialExamsOutlineProcessor)

has_pending_milestones(usage_key)#
inaccessible_sequences(full_course_outline)#

Returns the set of sequence usage keys for which the user has pending milestones

openedx.core.djangoapps.content.learning_sequences.api.processors.schedule module#

class openedx.core.djangoapps.content.learning_sequences.api.processors.schedule.ScheduleOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Responsible for applying all start/due/end date outline processing.

We never hide the existence of a piece of content because of start or due dates. Content may be inaccessible because it has yet to be released or the exam has closed, but students are never prevented from knowing the content exists based on the start and due date information.

This processor depends on edx-when to get customized due date information for users and content.

Things we don’t handle yet: * Beta test users * Things that are made inaccessible after they’re due.

inaccessible_sequences(full_course_outline)#

This might include Sequences that have not yet started, or Sequences for exams that have closed. If a Section has not started, all of its Sequences are inaccessible, regardless of the individual Sequence start dates.

load_data(full_course_outline)#

Pull dates information from edx-when.

Return data format: (usage_key, ‘due’): datetime.datetime(2019, 12, 11, 15, 0, tzinfo=<UTC>)

schedule_data(pruned_course_outline: UserCourseOutlineData) ScheduleData#

Return supplementary scheduling information for this outline.

Be careful to pass in a UserCourseOutlineData–i.e. an outline that has already been pruned to what a user is allowed to see. That way, we can use this to make sure that we’re not returning data about LearningSequences that the user can’t see because it was hidden by a different OutlineProcessor.

openedx.core.djangoapps.content.learning_sequences.api.processors.special_exams module#

As currently designed, this processor ignores the course specific Enable Timed Exams setting when determining whether or not it should remove keys and/or supplement exam data. This matches the exact behavior of MilestonesAndSpecialExamsTransformer. It is not entirely clear if the behavior should be modified, so it has been decided to consider any necessary fixes in a new ticket.

Please see the PR and discussion linked below for further context openedx/edx-platform#24545

class openedx.core.djangoapps.content.learning_sequences.api.processors.special_exams.SpecialExamsOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Responsible for applying all outline processing related to special exams.

exam_data(pruned_course_outline: UserCourseOutlineData) SpecialExamAttemptData#

Return supplementary special exam information for this outline.

Be careful to pass in a UserCourseOutlineData - i.e. an outline that has already been pruned to what a user is allowed to see. That way, we can use this to make sure that we’re not returning data about LearningSequences that the user can’t see because it was hidden by a different OutlineProcessor.

load_data(full_course_outline)#

Check if special exams are enabled

openedx.core.djangoapps.content.learning_sequences.api.processors.team_partition_groups module#

Outline processors for applying team user partition groups.

class openedx.core.djangoapps.content.learning_sequences.api.processors.team_partition_groups.TeamPartitionGroupsOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Processor for applying all user partition groups to the course outline.

This processor is used to remove content from the course outline based on the user’s team membership. It is used in the courseware API to remove content from the course outline before it is returned to the client.

load_data(_) None#

Pull team groups for this course and which group the user is in.

usage_keys_to_remove(full_course_outline)#

Content group exclusions remove the content entirely.

This method returns the usage keys of all content that should be removed from the course outline based on the user’s team membership. In this context, a team within a team-set maps to a user partition group.

openedx.core.djangoapps.content.learning_sequences.api.processors.visibility module#

Simple OutlineProcessor that removes items based on VisibilityData.

class openedx.core.djangoapps.content.learning_sequences.api.processors.visibility.VisibilityOutlineProcessor(course_key: CourseKey, user: User, at_time: datetime)#

Bases: OutlineProcessor

Simple OutlineProcessor that removes items based on VisibilityData.

We only remove items with this Processor, we never make them visible-but- inaccessible. There is no need to implement load_data because everything we need comes from the CourseOutlineData itself.

usage_keys_to_remove(full_course_outline)#

Remove anything flagged with hide_from_toc or visible_to_staff_only.

It’s possible to argue that we should include hide_from_toc items in the outline, but flag them in a special way. Students aren’t precisely forbidden from knowing that these items exist, they just aren’t supposed to see them in the course navigation. That being said, a) this is an obscure and long-deprecated feature; b) this implementation will preserve the behavior that students won’t see it (though staff will); and c) it simplifies REST API clients to never have to deal with the concept at all.

Module contents#