AA-454: Reenable CourseUpdateResolver for Instructor-paced Courses
When CourseNextSectionUpdate was created, it incorporated Personalized Learner Schedules logic which didn't take into account release dates of content and was only intended for self-paced courses that always have all content released. This caused a bug where instructor-paced courses could receive an update about content that had not been released yet. This PR turns the CourseUpdateResolver back on for instructor-paced courses so they can go back to receiving weekly highlights.
This commit is contained in:
@@ -14,7 +14,7 @@ from openedx.core.djangoapps.schedules.tasks import ScheduleCourseNextSectionUpd
|
||||
|
||||
class Command(SendEmailBaseCommand):
|
||||
"""
|
||||
Command to send Schedule course updates
|
||||
Command to send Schedule course updates for Self-paced Courses
|
||||
"""
|
||||
help = dedent(__doc__).strip()
|
||||
async_send_task = ScheduleCourseNextSectionUpdate
|
||||
|
||||
@@ -12,7 +12,7 @@ from openedx.core.djangoapps.schedules.tasks import ScheduleCourseUpdate
|
||||
|
||||
class Command(SendEmailBaseCommand):
|
||||
"""
|
||||
Command to send Schedule course updates
|
||||
Command to send Schedule course updates for Instructor-paced Courses
|
||||
"""
|
||||
help = dedent(__doc__).strip()
|
||||
async_send_task = ScheduleCourseUpdate
|
||||
|
||||
@@ -352,6 +352,8 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
|
||||
"""
|
||||
Send a message to all users whose schedule started at ``self.current_date`` + ``day_offset`` and the
|
||||
course has updates.
|
||||
|
||||
Only used for Instructor-paced Courses
|
||||
"""
|
||||
log_prefix = 'Course Update'
|
||||
schedule_date_field = 'start_date'
|
||||
@@ -359,9 +361,8 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
|
||||
experience_filter = Q(experience__experience_type=ScheduleExperience.EXPERIENCES.course_updates)
|
||||
|
||||
def send(self, msg_type):
|
||||
for (user, language, context, is_self_paced) in self.schedules_for_bin():
|
||||
msg_type = CourseUpdate() if is_self_paced else InstructorLedCourseUpdate()
|
||||
msg = msg_type.personalize(
|
||||
for (user, language, context) in self.schedules_for_bin():
|
||||
msg = InstructorLedCourseUpdate().personalize(
|
||||
Recipient(
|
||||
user.username,
|
||||
self.override_recipient_email or user.email,
|
||||
@@ -384,6 +385,11 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
|
||||
course = schedule.enrollment.course
|
||||
user = enrollment.user
|
||||
|
||||
# (Weekly) Course Updates are only for Instructor-paced courses.
|
||||
# See CourseNextSectionUpdate for Self-paced updates.
|
||||
if course.self_paced:
|
||||
continue
|
||||
|
||||
try:
|
||||
week_highlights = get_week_highlights(user, enrollment.course_id, week_num)
|
||||
except CourseUpdateDoesNotExist:
|
||||
@@ -415,13 +421,15 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
|
||||
})
|
||||
template_context.update(_get_upsell_information_for_schedule(user, schedule))
|
||||
|
||||
yield (user, schedule.enrollment.course.closest_released_language, template_context, course.self_paced)
|
||||
yield (user, schedule.enrollment.course.closest_released_language, template_context)
|
||||
|
||||
|
||||
@attr.s
|
||||
class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
|
||||
"""
|
||||
Send a message to all users whose schedule gives them a due date of yesterday.
|
||||
|
||||
Only used for Self-paced Courses
|
||||
"""
|
||||
async_send_task = attr.ib()
|
||||
site = attr.ib()
|
||||
@@ -434,9 +442,8 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
|
||||
|
||||
def send(self):
|
||||
schedules = self.get_schedules()
|
||||
for (user, language, context, is_self_paced) in schedules:
|
||||
msg_type = CourseUpdate() if is_self_paced else InstructorLedCourseUpdate()
|
||||
msg = msg_type.personalize(
|
||||
for (user, language, context) in schedules:
|
||||
msg = CourseUpdate().personalize(
|
||||
Recipient(
|
||||
user.username,
|
||||
self.override_recipient_email or user.email,
|
||||
@@ -477,6 +484,11 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
|
||||
if course.end and course.end.date() <= target_date:
|
||||
return
|
||||
|
||||
# Next Section Updates are only for Self-paced courses since it uses Personalized
|
||||
# Learner Schedule logic. See CourseUpdateResolver for Instructor-paced updates
|
||||
if not course.self_paced:
|
||||
continue
|
||||
|
||||
user = schedule.enrollment.user
|
||||
start_date = max(filter(None, (schedule.start_date, course.start)))
|
||||
LOG.info('Received a schedule for user {} in course {} for date {}'.format(
|
||||
@@ -512,7 +524,7 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
|
||||
})
|
||||
template_context.update(_get_upsell_information_for_schedule(user, schedule))
|
||||
|
||||
yield (user, course.closest_released_language, template_context, course.self_paced)
|
||||
yield (user, course.closest_released_language, template_context)
|
||||
|
||||
|
||||
def _get_trackable_course_home_url(course_id):
|
||||
|
||||
@@ -103,7 +103,7 @@ class TestCourseUpdateResolver(SchedulesResolverTestMixin, ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create(highlights_enabled_for_messaging=True, self_paced=True)
|
||||
self.course = CourseFactory.create(highlights_enabled_for_messaging=True)
|
||||
with self.store.bulk_operations(self.course.id):
|
||||
ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff'])
|
||||
|
||||
@@ -145,7 +145,7 @@ class TestCourseUpdateResolver(SchedulesResolverTestMixin, ModuleStoreTestCase):
|
||||
'week_highlights': ['good stuff'],
|
||||
'week_num': 1,
|
||||
}
|
||||
self.assertEqual(schedules, [(self.user, None, expected_context, True)])
|
||||
self.assertEqual(schedules, [(self.user, None, expected_context)])
|
||||
|
||||
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
|
||||
@override_switch('schedules.course_update_show_unsubscribe', True)
|
||||
@@ -235,7 +235,7 @@ class TestCourseNextSectionUpdateResolver(SchedulesResolverTestMixin, ModuleStor
|
||||
'week_highlights': ['good stuff 2'],
|
||||
'week_num': 2,
|
||||
}
|
||||
self.assertEqual(schedules, [(self.user, None, expected_context, True)])
|
||||
self.assertEqual(schedules, [(self.user, None, expected_context)])
|
||||
|
||||
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
|
||||
@override_switch('schedules.course_update_show_unsubscribe', True)
|
||||
|
||||
Reference in New Issue
Block a user