AA-454 and AA-470: Update language and bug fix for highlights

Since Course Highlights aren't necessarily weekly (self-paced courses),
update the language to be more generic. And then includes a bug fix to
not send highlights to learners after they have unenrolled from a course.
This commit is contained in:
Dillon Dumesnil
2020-12-04 13:24:26 +00:00
parent ef5832bc74
commit 9e2eab506f
6 changed files with 26 additions and 7 deletions

View File

@@ -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.
"""

View File

@@ -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,

View File

@@ -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
"""