This was the "outline tab" view of the course. Preceded by the
course info view, succeeded by the MFE outline tab.
In addition to the course home view itself, this drops related
features:
- Legacy version of Course Goals (MFE has a newer implementation)
- Course home in-course search (MFE has no search)
The old course info view and course about views survive for now.
This also drops a few now-unused feature toggles:
- course_experience.latest_update
- course_experience.show_upgrade_msg_on_course_home
- course_experience.upgrade_deadline_message
- course_home.course_home_use_legacy_frontend
With this change, just the progress and courseware tabs are still
supported in legacy form, if you opt-in with waffle flags. The
outline and dates tabs are offered only by the MFE.
AA-798
(This is identical to previous commit be5c1a6, just reintroduced
now that the e2e tests have been fixed)
110 lines
5.0 KiB
Python
110 lines
5.0 KiB
Python
"""
|
|
Unified course experience settings and helper methods.
|
|
"""
|
|
|
|
from django.urls import reverse
|
|
from django.utils.translation import gettext as _
|
|
from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace
|
|
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
|
|
|
|
|
# Namespace for course experience waffle flags.
|
|
WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='course_experience')
|
|
|
|
# Waffle flag to disable the separate course outline page and full width content.
|
|
DISABLE_COURSE_OUTLINE_PAGE_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
WAFFLE_FLAG_NAMESPACE, 'disable_course_outline_page', __name__
|
|
)
|
|
|
|
# Waffle flag to enable a single unified "Course" tab.
|
|
DISABLE_UNIFIED_COURSE_TAB_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
WAFFLE_FLAG_NAMESPACE, 'disable_unified_course_tab', __name__
|
|
)
|
|
|
|
# Waffle flag to enable the sock on the footer of the home and courseware pages.
|
|
DISPLAY_COURSE_SOCK_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'display_course_sock', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
|
|
# Waffle flag to let learners access a course before its start date.
|
|
COURSE_PRE_START_ACCESS_FLAG = LegacyWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'pre_start_access', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
|
|
# .. toggle_name: course_experience.enable_course_goals
|
|
# .. toggle_implementation: CourseWaffleFlag
|
|
# .. toggle_default: False
|
|
# .. toggle_description: Used to determine whether or not to use course goals for the particular course.
|
|
# .. toggle_use_cases: opt_out, temporary
|
|
# .. toggle_creation_date: 2017-09-11
|
|
# .. toggle_target_removal_date: None
|
|
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
|
|
ENABLE_COURSE_GOALS = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'enable_course_goals', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
|
|
# Waffle flag to enable anonymous access to a course
|
|
SEO_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='seo')
|
|
COURSE_ENABLE_UNENROLLED_ACCESS_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
SEO_WAFFLE_FLAG_NAMESPACE,
|
|
'enable_anonymous_courseware_access',
|
|
__name__,
|
|
)
|
|
|
|
# .. toggle_name: course_experience.relative_dates
|
|
# .. toggle_implementation: CourseWaffleFlag
|
|
# .. toggle_default: False
|
|
# .. toggle_description: Waffle flag to enable relative dates for course content. A 'Dates' tab will be visible in the
|
|
# course view showing key course dates. Was previously an ExperimentWaffleFlag with experiment_id=17.
|
|
# .. toggle_use_cases: opt_in
|
|
# .. toggle_creation_date: 2020-02-10
|
|
# .. toggle_warnings: To set a relative due date for self-paced courses, the weeks_to_complete field for a course run
|
|
# needs to be set. Currently it can be set through the publisher app.
|
|
# .. toggle_tickets: https://openedx.atlassian.net/browse/AA-27
|
|
RELATIVE_DATES_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'relative_dates', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
|
|
# .. toggle_name: course_experience.calendar_sync
|
|
# .. toggle_implementation: CourseWaffleFlag
|
|
# .. toggle_default: False
|
|
# .. toggle_description: This course flag enables a course tool (which is a tool that is added on a course home page)
|
|
# that sends course assignment calendars to course students, whenever they click on the "Subscribe to calendar
|
|
# updates" button. The email contains an ics attachment that students can then use to sync with their own calendar
|
|
# apps.
|
|
# .. toggle_warnings: For this toggle to have an effect, the RELATIVE_DATES_FLAG toggle must be enabled, too.
|
|
# .. toggle_use_cases: temporary
|
|
# .. toggle_creation_date: 2021-01-26
|
|
# .. toggle_target_removal_date: 2021-04-26
|
|
# .. toggle_tickets: https://openedx.atlassian.net/browse/AA-36
|
|
CALENDAR_SYNC_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'calendar_sync', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation
|
|
|
|
|
|
def course_home_page_title(_course):
|
|
"""
|
|
Returns the title for the course home page.
|
|
"""
|
|
return _('Course')
|
|
|
|
|
|
def default_course_url(course_key):
|
|
"""
|
|
Returns the default course URL for the current user.
|
|
|
|
Arguments:
|
|
course_key (CourseKey): The course id of the current course.
|
|
"""
|
|
from .url_helpers import get_learning_mfe_home_url
|
|
|
|
if DISABLE_COURSE_OUTLINE_PAGE_FLAG.is_enabled(course_key):
|
|
return reverse('courseware', args=[str(course_key)])
|
|
|
|
return get_learning_mfe_home_url(course_key, url_fragment='home')
|
|
|
|
|
|
def course_home_url(course_key):
|
|
"""
|
|
Returns the course home page's URL for the current user.
|
|
|
|
Arguments:
|
|
course_key (CourseKey): The course key for which the home url is being requested.
|
|
"""
|
|
from .url_helpers import get_learning_mfe_home_url
|
|
|
|
if DISABLE_UNIFIED_COURSE_TAB_FLAG.is_enabled(course_key):
|
|
return reverse('info', args=[str(course_key)])
|
|
|
|
return get_learning_mfe_home_url(course_key, url_fragment='home')
|