Skip to content

Commit

Permalink
fix: AA-1058: Bust cache when Schedules are updated
Browse files Browse the repository at this point in the history
We had a bug reported where learners would reset their due dates
for their Personalized Learner Schedule, but the dates wouldn't
update. This was a result of the cache key not changing, so this
fix adds in the learner's schedule to the transformer.
  • Loading branch information
Dillon-Dumesnil committed Oct 20, 2021
1 parent a9e78e8 commit f32dbe2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Change Log
Unreleased
~~~~~~~~~~

[2.2.2] - 2021-10-21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Bug fix to bust cache when Personalized Learner Schedules are updated.

[2.2.1] - 2021-09-15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Bug fix for optimization in 2.2.0, to account for missing block_type data.
Expand Down
2 changes: 1 addition & 1 deletion edx_when/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Central source of course block dates for the LMS.
"""

__version__ = '2.2.1'
__version__ = '2.2.2'

default_app_config = 'edx_when.apps.EdxWhenConfig' # pylint: disable=invalid-name
17 changes: 16 additions & 1 deletion edx_when/field_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

from . import api

try:
from openedx.core.djangoapps.schedules.models import Schedule
# TODO: Move schedules into edx-when
except ImportError:
Schedule = None

try:
from xmodule.modulestore.inheritance import InheritanceMixin
INHERITABLE_FIELDS = set(InheritanceMixin.fields.keys())
Expand Down Expand Up @@ -155,7 +161,16 @@ def transform(self, usage_info, block_structure):
"""
Load override data into blocks.
"""
dates = api.get_dates_for_course(usage_info.course_key, self.user)
schedule = None
if Schedule:
try:
schedule = Schedule.objects.get(
enrollment__user=self.user, enrollment__course__id=usage_info.course_key
)
except Schedule.ObjectDoesNotExist:
pass

dates = api.get_dates_for_course(usage_info.course_key, self.user, schedule=schedule)
for (location, field), date in dates.items():
try:
block_structure.override_xblock_field(
Expand Down

0 comments on commit f32dbe2

Please sign in to comment.