Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3260,7 +3260,7 @@ class TestShowCoursewareMFE(TestCase):
* user is member of the course team
* whether the course_key is an old Mongo style of key
* the COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW CourseWaffleFlag
* the REDIRECT_TO_COURSEWARE_MICROFRONTEND CourseWaffleFlag
* the REDIRECT_TO_COURSEWARE_MICROFRONTEND ExperimentWaffleFlag

Giving us theoretically 2^6 = 64 states. >_<
"""
Expand Down
9 changes: 5 additions & 4 deletions lms/djangoapps/courseware/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
"""

from django.conf import settings
from lms.djangoapps.experiments.flags import ExperimentWaffleFlag
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace

# Namespace for courseware waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='courseware')

# Waffle flag to redirect to another learner profile experience.
# .. toggle_name: courseware.redirect_to_microfrontend
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_name: courseware.courseware_mfe
# .. toggle_implementation: ExperimentWaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports staged rollout to students for a new micro-frontend-based implementation of the courseware page.
# .. toggle_category: micro-frontend
# .. toggle_use_cases: incremental_release, open_edx
# .. toggle_creation_date: 2020-01-29
# .. toggle_expiration_date: 2020-12-31
# .. toggle_warnings: Also set settings.LEARNING_MICROFRONTEND_URL and ENABLE_COURSEWARE_MICROFRONTEND.
# .. toggle_tickets: TNL-6982
# .. toggle_tickets: TNL-7000
# .. toggle_status: supported
REDIRECT_TO_COURSEWARE_MICROFRONTEND = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'redirect_to_microfrontend')
REDIRECT_TO_COURSEWARE_MICROFRONTEND = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'courseware_mfe')

# Waffle flag to display a link for the new learner experience to course teams without redirecting students.
#
Expand Down
10 changes: 7 additions & 3 deletions lms/djangoapps/courseware/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
from ..model_data import FieldDataCache
from ..module_render import get_module_for_descriptor, toc_for_course
from ..permissions import MASQUERADE_AS_STUDENT
from ..toggles import COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, should_redirect_to_courseware_microfrontend
from ..toggles import (
COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW,
REDIRECT_TO_COURSEWARE_MICROFRONTEND,
should_redirect_to_courseware_microfrontend,
)
from ..url_helpers import get_microfrontend_url

from .views import CourseTabView
Expand Down Expand Up @@ -715,9 +719,9 @@ def show_courseware_mfe_link(user, staff_access, course_key):
# course team preview CourseWaffleFlag for this course *or* if we've turned
# on the redirect for your students.
mfe_enabled_for_course_team = COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW.is_enabled(course_key)
mfe_enabled_for_students = should_redirect_to_courseware_microfrontend(course_key)
mfe_experiment_enabled_for_course = REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_experiment_on(course_key)

if staff_access and (mfe_enabled_for_course_team or mfe_enabled_for_students):
if staff_access and (mfe_enabled_for_course_team or mfe_experiment_enabled_for_course):
return True

return False
3 changes: 3 additions & 0 deletions lms/djangoapps/experiments/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def is_enabled(self, course_key=None):
def is_enabled_without_course_context(self):
return self.is_enabled()

def is_experiment_on(self, course_key=None):
return super().is_enabled(course_key)

@contextmanager
def override(self, active=True, bucket=1): # pylint: disable=arguments-differ
from mock import patch
Expand Down