From a15673f3de30737c83b8356a90f6b3fd5bf540a5 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Tue, 17 Mar 2020 11:01:45 -0400 Subject: [PATCH 1/5] Swap courseware mfe CourseWaffleFlag with ExperimentWaffleFlag TNL-7000 --- lms/djangoapps/courseware/toggles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index b4021873950b..807ec97b9d53 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -3,7 +3,7 @@ """ from django.conf import settings -from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace +from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, ExperimentWaffleFlag, WaffleFlagNamespace # Namespace for courseware waffle flags. WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='courseware') @@ -20,7 +20,7 @@ # .. toggle_warnings: Also set settings.LEARNING_MICROFRONTEND_URL and ENABLE_COURSEWARE_MICROFRONTEND. # .. toggle_tickets: TNL-6982 # .. 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. # From f2e7c685b2bd2223d8d414e2627be9e819ae0f08 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Tue, 17 Mar 2020 11:21:44 -0400 Subject: [PATCH 2/5] Update toggles.py --- lms/djangoapps/courseware/toggles.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index 807ec97b9d53..69c50f6f75b9 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -3,14 +3,15 @@ """ from django.conf import settings -from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, ExperimentWaffleFlag, WaffleFlagNamespace +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_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 From 379bf2981f50ee0ff9f427b12340b21a92370a00 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Wed, 18 Mar 2020 17:45:48 -0400 Subject: [PATCH 3/5] add is_enabled_for_course to experiment waffle flag --- lms/djangoapps/courseware/tests/test_views.py | 2 +- lms/djangoapps/courseware/toggles.py | 6 +++--- lms/djangoapps/courseware/views/index.py | 10 +++++++--- lms/djangoapps/experiments/flags.py | 3 +++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 1262030044d6..d4b10f6e51a7 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -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. >_< """ diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index 69c50f6f75b9..8055b60cfbee 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -10,7 +10,7 @@ WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='courseware') # Waffle flag to redirect to another learner profile experience. -# .. toggle_name: courseware.redirect_to_microfrontend +# .. 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. @@ -19,9 +19,9 @@ # .. 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 = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'courseware-mfe') +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. # diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index a0b83ac1c4f4..0ab3e6fd51d0 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -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 @@ -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_enabled_for_course(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 diff --git a/lms/djangoapps/experiments/flags.py b/lms/djangoapps/experiments/flags.py index 3d0afa8e7df3..5e76ff2481f5 100644 --- a/lms/djangoapps/experiments/flags.py +++ b/lms/djangoapps/experiments/flags.py @@ -138,6 +138,9 @@ def is_enabled(self, course_key=None): def is_enabled_without_course_context(self): return self.is_enabled() + def is_enabled_for_course(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 From a0b6b9aacae26998f9d2d50b3b2c44b0e057a809 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Thu, 19 Mar 2020 11:27:12 -0400 Subject: [PATCH 4/5] lint --- lms/djangoapps/courseware/views/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 0ab3e6fd51d0..7c93095abdc5 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -82,7 +82,7 @@ from ..toggles import ( COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, REDIRECT_TO_COURSEWARE_MICROFRONTEND, - should_redirect_to_courseware_microfrontend + should_redirect_to_courseware_microfrontend, ) from ..url_helpers import get_microfrontend_url From dc64e5cf251c72a5653b97fb42aa27f664a0b229 Mon Sep 17 00:00:00 2001 From: Adam Butterworth Date: Thu, 19 Mar 2020 12:27:54 -0400 Subject: [PATCH 5/5] rename is_experiment_on --- lms/djangoapps/courseware/views/index.py | 2 +- lms/djangoapps/experiments/flags.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 7c93095abdc5..8d080272cd1e 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -719,7 +719,7 @@ 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_experiment_enabled_for_course = REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled_for_course(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_experiment_enabled_for_course): return True diff --git a/lms/djangoapps/experiments/flags.py b/lms/djangoapps/experiments/flags.py index 5e76ff2481f5..d0070eb7e85d 100644 --- a/lms/djangoapps/experiments/flags.py +++ b/lms/djangoapps/experiments/flags.py @@ -138,7 +138,7 @@ def is_enabled(self, course_key=None): def is_enabled_without_course_context(self): return self.is_enabled() - def is_enabled_for_course(self, course_key=None): + def is_experiment_on(self, course_key=None): return super().is_enabled(course_key) @contextmanager