diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 7e5996b7c74a0bb29a35c785bffc072abd02824c..7419a0ae10778aa0a5d416145bdd8474004f362c 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -273,7 +273,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview', }, getTitle: function() { - return gettext('Enable Weekly Highlight Emails'); + return gettext('Enable Course Highlight Emails'); }, getIntroductionMessage: function() { diff --git a/cms/templates/js/course-highlights-enable.underscore b/cms/templates/js/course-highlights-enable.underscore index 2b3ea55d5c8ff6100addeb365f9b9900f67ca8d4..cfc9c9ac1e1a25fad63586a2d2356374cbb7f5e9 100644 --- a/cms/templates/js/course-highlights-enable.underscore +++ b/cms/templates/js/course-highlights-enable.underscore @@ -1,6 +1,6 @@ <div class="course-highlights-setting"> <h2 id="highlights-enabled-label" class="status-highlights-enabled-label"> - <%- gettext('Weekly Highlight Emails') %> + <%- gettext('Course Highlight Emails') %> </h2> <br> <% if (highlights_enabled_for_messaging) { %> diff --git a/cms/templates/js/highlights-enable-editor.underscore b/cms/templates/js/highlights-enable-editor.underscore index 954111307242d143fea5145c7795d15ba27453d4..1159b20a45232972b917c11e1b264ca4bb26d0dd 100644 --- a/cms/templates/js/highlights-enable-editor.underscore +++ b/cms/templates/js/highlights-enable-editor.underscore @@ -1,7 +1,7 @@ <p> <%- gettext( - 'When you enable weekly highlight emails, learners ' + - 'automatically receive weekly email messages for each section that ' + + 'When you enable course highlight emails, learners ' + + 'automatically receive email messages for each section that ' + 'has highlights. You cannot disable highlights after you start ' + 'sending them.' ) %> @@ -10,7 +10,7 @@ <% // xss-lint: disable=underscore-not-escaped %> <%= edx.HtmlUtils.interpolateHtml( gettext( - 'Are you sure you want to enable weekly highlight emails? ' + 'Are you sure you want to enable course highlight emails? ' + '{linkStart}Learn more.{linkEnd}' ), { diff --git a/openedx/core/djangoapps/schedules/content_highlights.py b/openedx/core/djangoapps/schedules/content_highlights.py index 670fe427c638cb9149c1640349f7836b6ceee0e9..d329c3f38fe35abc85c9b5e0ff0e7b9168398027 100644 --- a/openedx/core/djangoapps/schedules/content_highlights.py +++ b/openedx/core/djangoapps/schedules/content_highlights.py @@ -1,5 +1,5 @@ """ -Contains methods for accessing weekly course highlights. Weekly highlights is a +Contains methods for accessing course highlights. Course highlights is a schedule experience built on the Schedules app. """ diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py index 79c80d9e6e00ee98d7646b72b61645dadde2ee60..839a5b7298de2b109a2261df87f6595540637fca 100644 --- a/openedx/core/djangoapps/schedules/resolvers.py +++ b/openedx/core/djangoapps/schedules/resolvers.py @@ -471,6 +471,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver): schedules = Schedule.objects.select_related('enrollment').filter( self.experience_filter, active=True, + enrollment__is_active=True, enrollment__course_id=self.course_id, enrollment__user__is_active=True, start_date__gte=target_date - course_duration, diff --git a/openedx/core/djangoapps/schedules/signals.py b/openedx/core/djangoapps/schedules/signals.py index 09ef4cc9fd970e99279d7815419e014f248e28cb..c5a7ca6af4e5239b83cb8a7ae1874b5c1e371472 100644 --- a/openedx/core/djangoapps/schedules/signals.py +++ b/openedx/core/djangoapps/schedules/signals.py @@ -23,7 +23,7 @@ from openedx.core.djangoapps.schedules.models import ScheduleExperience from openedx.core.djangoapps.schedules.utils import reset_self_paced_schedule from openedx.core.djangoapps.theming.helpers import get_current_site from common.djangoapps.student.models import CourseEnrollment -from common.djangoapps.student.signals import ENROLLMENT_TRACK_UPDATED +from common.djangoapps.student.signals import ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED from common.djangoapps.track import segment from .config import CREATE_SCHEDULE_WAFFLE_FLAG @@ -61,6 +61,24 @@ def create_schedule(sender, **kwargs): # pylint: disable=unused-argument )) +@receiver(ENROLL_STATUS_CHANGE) +def update_schedule(sender, event, user, course_id, **kwargs): # pylint: disable=unused-argument + """ + When a CourseEnrollment's status is updated, update the Schedule's active status if configured. + """ + try: + schedule = Schedule.objects.get(enrollment__user=user, enrollment__course=course_id) + except Schedule.DoesNotExist: + # Exit since it could just be an indication of Schedules are not enabled. + return + + if event == 'enroll': + schedule.active = True + elif event == 'unenroll': + schedule.active = False + schedule.save() + + @receiver(COURSE_START_DATE_CHANGED) def update_schedules_on_course_start_changed(sender, updated_course_overview, previous_start_date, **kwargs): # pylint: disable=unused-argument """