openedx.features.course_duration_limits package#
Submodules#
openedx.features.course_duration_limits.access module#
Contains code related to computing content gating course duration limits and course access based on these limits.
- class openedx.features.course_duration_limits.access.AuditExpiredError(user, course, expiration_date)#
Bases:
AccessErrorAccess denied because the user’s audit timespan has expired
- openedx.features.course_duration_limits.access.check_course_expired(user, course)#
Check if the course expired for the user.
- openedx.features.course_duration_limits.access.course_expiration_wrapper(user, block, view, frag, context)#
An XBlock wrapper that prepends a message to the beginning of a vertical if a user’s course is about to expire.
- openedx.features.course_duration_limits.access.generate_course_expired_fragment(user, course)#
- openedx.features.course_duration_limits.access.generate_course_expired_fragment_from_key(user, course_key)#
Like generate_course_expired_fragment, but using a CourseKey instead of a CourseOverview and using request-level caching.
Either returns WebFragment to inject XBlock content into, or None if we shouldn’t show a course expired message for this user.
- openedx.features.course_duration_limits.access.generate_course_expired_message(user, course)#
Generate the message for the user course expiration date if it exists.
- openedx.features.course_duration_limits.access.generate_fragment_from_message(message)#
- openedx.features.course_duration_limits.access.get_access_expiration_data(user, course)#
Create a dictionary of information about the access expiration for this user & course.
Used by serializers to pass onto frontends and by the LMS locally to generate HTML for template rendering.
Returns a dictionary of data, or None if no expiration is applicable.
- openedx.features.course_duration_limits.access.get_user_course_duration(user, course)#
Return a timedelta measuring the duration of the course for a particular user.
- Business Logic:
Course access duration is bounded by the min and max duration.
If course fields are missing, default course access duration to MIN_DURATION.
- openedx.features.course_duration_limits.access.get_user_course_expiration_date(user, course, enrollment=None)#
Return expiration date for given user course pair. Return None if the course does not expire.
- Business Logic:
Course access duration is bounded by the min and max duration.
If course fields are missing, default course access duration to MIN_DURATION.
openedx.features.course_duration_limits.apps module#
Course duration limits application configuration
openedx.features.course_duration_limits.config module#
Content type gating waffle flag
openedx.features.course_duration_limits.models module#
Course Duration Limit Configuration Models
- class openedx.features.course_duration_limits.models.CourseDurationLimitConfig(*args, **kwargs)#
Bases:
StackedConfigurationModelConfiguration to manage the Course Duration Limit facility.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- STACKABLE_FIELDS = ('enabled', 'enabled_as_of')#
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- clean()#
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- course#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- course_id#
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enabled_as_of#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enabled_as_of_datetime(target_datetime)#
Return whether this Course Duration Limit configuration context is enabled as of a date and time.
- Parameters:
target_datetime (
datetime.datetime) – The datetime thatenabled_as_ofmust be equal to or before
- classmethod enabled_for_course(course_key, target_datetime=None)#
Return whether Course Duration Limits are enabled for this course as of a particular date.
Course Duration Limits are enabled for a course on a date if they are enabled either specifically, or via a containing context, such as the org, site, or globally, and if the configuration is specified to be
enabled_as_ofbeforetarget_datetime.Only one of enrollment and (user, course_key) may be specified at a time.
- Parameters:
course_key – The CourseKey of the course being queried.
target_datetime – The datetime to checked enablement as of. Defaults to the current date and time.
- classmethod enabled_for_enrollment(user, course)#
Return whether Course Duration Limits are enabled for this enrollment.
Course Duration Limits are enabled for an enrollment if they are enabled for the course being enrolled in (either specifically, or via a containing context, such as the org, site, or globally), and if the configuration is specified to be
enabled_as_ofbefore the enrollment was created.- Parameters:
user – The user being queried.
course_key – The CourseKey of the course being queried.
course – The CourseOverview object being queried.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- org#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- org_course#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- site#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- site_id#