Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
import json
from collections import OrderedDict
from datetime import timedelta
from unittest.mock import Mock

from django.contrib import messages
Expand All @@ -25,6 +24,7 @@
from lms.djangoapps.courseware.masquerade import setup_masquerade
from lms.djangoapps.lms_xblock.field_data import LmsFieldData
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.course_date_signals.utils import get_expected_duration
from openedx.core.lib.url_utils import quote_slashes
from common.djangoapps.student.models import CourseEnrollment, Registration
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
Expand Down Expand Up @@ -417,7 +417,7 @@ def get_expiration_banner_text(user, course, language='en'): # lint-amnesty, py
"""
upgrade_link = verified_upgrade_deadline_link(user=user, course=course)
enrollment = CourseEnrollment.get_enrollment(user, course.id)
expiration_date = enrollment.created + timedelta(weeks=4)
expiration_date = enrollment.created + get_expected_duration(course.id)
upgrade_deadline = enrollment.upgrade_deadline
if upgrade_deadline is None or now() < upgrade_deadline:
upgrade_deadline = enrollment.course_upgrade_deadline
Expand Down
3 changes: 2 additions & 1 deletion openedx/core/djangoapps/course_date_signals/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def test_extract_dates_from_course_custom_and_default_pls_one_subsection(self):
(sequential.location, {'due': timedelta(days=21)})
]
course = self.store.get_item(self.course.location)
self.assertCountEqual(extract_dates_from_course(course), expected_dates)
with patch.object(utils, 'get_expected_duration', return_value=timedelta(weeks=4)):
self.assertCountEqual(extract_dates_from_course(course), expected_dates) # noqa: PT009

@override_waffle_flag(CUSTOM_RELATIVE_DATES, active=True)
def test_extract_dates_from_course_custom_and_default_pls_one_subsection_graded(self):
Expand Down
6 changes: 4 additions & 2 deletions openedx/core/djangoapps/course_date_signals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

from datetime import timedelta

from django.conf import settings

from openedx.core.djangoapps.catalog.utils import get_course_run_details


MIN_DURATION = timedelta(weeks=4)
MAX_DURATION = timedelta(weeks=18)
MIN_DURATION = timedelta(weeks=settings.COURSE_ACCESS_DURATION_MIN_WEEKS)
MAX_DURATION = timedelta(weeks=settings.COURSE_ACCESS_DURATION_MAX_WEEKS)


def get_expected_duration(course_id):
Expand Down
3 changes: 3 additions & 0 deletions openedx/core/djangoapps/schedules/tests/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import crum
import ddt
import pytz

from unittest.mock import patch # lint-amnesty, pylint: disable=wrong-import-order
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
Expand Down Expand Up @@ -226,6 +228,7 @@ def test_get_schedules_with_target_date_by_bin_and_orgs_filter_inactive_users(se
assert schedules.count() == 0


@patch('openedx.core.djangoapps.course_date_signals.utils.MIN_DURATION', datetime.timedelta(weeks=4))
@skip_unless_lms
class TestCourseNextSectionUpdateResolver(SchedulesResolverTestMixin, ModuleStoreTestCase):
"""
Expand Down
13 changes: 13 additions & 0 deletions openedx/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2441,3 +2441,16 @@ def should_send_learning_badge_events(settings):
COURSE_LIVE_GLOBAL_CREDENTIALS = {}

BEAMER_PRODUCT_ID = ""

# .. setting_name: COURSE_ACCESS_DURATION_MIN_WEEKS
# .. setting_default: 1
# .. setting_description: Minimum course duration in weeks when Discovery service data is unavailable or course has no
# .. weeks_to_complete value. Used as fallback for course access duration calculations (e.g., audit access expiration
# .. and discussion notification filtering).
COURSE_ACCESS_DURATION_MIN_WEEKS = 1

# .. setting_name: COURSE_ACCESS_DURATION_MAX_WEEKS
# .. setting_default: 18
# .. setting_description: Maximum course duration in weeks. Course access duration is bounded by this upper limit
# .. regardless of Discovery service data.
COURSE_ACCESS_DURATION_MAX_WEEKS = 18
Loading