From 080f04c18ce1c002aaeb927216e4f34e876e9afd Mon Sep 17 00:00:00 2001 From: Carla Duarte Date: Wed, 30 Sep 2020 16:32:33 -0400 Subject: [PATCH] AA-371: Progress Milestone Waffle Flags --- .../djangoapps/student/signals/receivers.py | 6 +-- .../student/tests/test_receivers.py | 8 +++- lms/djangoapps/courseware/toggles.py | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/student/signals/receivers.py b/common/djangoapps/student/signals/receivers.py index b6f0d60415..e4f7a17268 100644 --- a/common/djangoapps/student/signals/receivers.py +++ b/common/djangoapps/student/signals/receivers.py @@ -10,7 +10,7 @@ from django.db import IntegrityError from django.db.models.signals import post_save, pre_save from django.dispatch import receiver -from lms.djangoapps.courseware.toggles import REDIRECT_TO_COURSEWARE_MICROFRONTEND +from lms.djangoapps.courseware.toggles import courseware_mfe_first_section_celebration_is_active from student.helpers import EMAIL_EXISTS_MSG_FMT, USERNAME_EXISTS_MSG_FMT, AccountValidationError from student.models import CourseEnrollment, CourseEnrollmentCelebration, is_email_retired, is_username_retired @@ -58,8 +58,8 @@ def create_course_enrollment_celebration(sender, instance, created, **kwargs): return # The UI for celebrations is only supported on the MFE right now, so don't turn on - # celebrations unless this enrollment's course is MFE-enabled. - if not REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(instance.course_id): + # celebrations unless this enrollment's course is MFE-enabled and has milestones enabled. + if not courseware_mfe_first_section_celebration_is_active(instance.course_id): return try: diff --git a/common/djangoapps/student/tests/test_receivers.py b/common/djangoapps/student/tests/test_receivers.py index 07f65a8a03..5fddccbda4 100644 --- a/common/djangoapps/student/tests/test_receivers.py +++ b/common/djangoapps/student/tests/test_receivers.py @@ -1,6 +1,10 @@ """ Tests for student signal receivers. """ -from lms.djangoapps.courseware.toggles import REDIRECT_TO_COURSEWARE_MICROFRONTEND +from lms.djangoapps.courseware.toggles import ( + REDIRECT_TO_COURSEWARE_MICROFRONTEND, + COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES, + COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_FIRST_SECTION_CELEBRATION +) from student.models import CourseEnrollmentCelebration from student.tests.factories import CourseEnrollmentFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase @@ -11,6 +15,8 @@ class ReceiversTest(SharedModuleStoreTestCase): Tests for dashboard utility functions """ @REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True) + @COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES.override(active=True) + @COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_FIRST_SECTION_CELEBRATION.override(active=True) def test_celebration_created(self): """ Test that we make celebration objects when enrollments are created """ self.assertEqual(CourseEnrollmentCelebration.objects.count(), 0) diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index d700a395fe..666ab825a9 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -55,9 +55,47 @@ COURSEWARE_MICROFRONTEND_COURSE_EXIT_PAGE = CourseWaffleFlag( WAFFLE_FLAG_NAMESPACE, 'microfrontend_course_exit_page', __name__ ) +# .. toggle_name: courseware.mfe_progress_milestones +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: Waffle flag to display learner progress milestones in a course. Supports staged +# rollout to students for a new micro-frontend-based implementation of the courseware page. +# .. toggle_use_cases: temporary, open_edx +# .. toggle_creation_date: 2020-10-07 +# .. toggle_target_removal_date: none +# .. toggle_warnings: Also set settings.LEARNING_MICROFRONTEND_URL and ENABLE_COURSEWARE_MICROFRONTEND. +# .. toggle_tickets: AA-371 +COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES = CourseWaffleFlag( + WAFFLE_FLAG_NAMESPACE, 'mfe_progress_milestones', __name__ +) + +# .. toggle_name: courseware.mfe_progress_milestones_first_section_celebration +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: Waffle flag to display a celebration modal on learner completion of their first section. +# Supports staged rollout to students for a new micro-frontend-based implementation of the +# courseware page. +# .. toggle_use_cases: temporary, open_edx +# .. toggle_creation_date: 2020-10-07 +# .. toggle_target_removal_date: none +# .. toggle_warnings: Also set settings.LEARNING_MICROFRONTEND_URL and ENABLE_COURSEWARE_MICROFRONTEND and +# COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES. +# .. toggle_tickets: AA-371 +COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_FIRST_SECTION_CELEBRATION = CourseWaffleFlag( + WAFFLE_FLAG_NAMESPACE, 'mfe_progress_milestones_first_section_celebration', __name__ +) + def course_exit_page_is_active(course_key): return ( REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(course_key) and COURSEWARE_MICROFRONTEND_COURSE_EXIT_PAGE.is_enabled(course_key) ) + + +def courseware_mfe_first_section_celebration_is_active(course_key): + return ( + REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(course_key) and + COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES.is_enabled(course_key) and + COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_FIRST_SECTION_CELEBRATION.is_enabled(course_key) + )