Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [AXIMST-806] change course version to edited timestamp #2542

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lms/djangoapps/course_home_api/outline/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
get_current_update_for_user
)
from openedx.features.course_experience.url_helpers import get_learning_mfe_home_url
from openedx.features.course_experience.utils import get_course_outline_block_tree, get_start_block
from openedx.features.course_experience.utils import (
get_course_outline_block_tree,
get_course_outline_block_tree_with_cache,
get_start_block
)
from openedx.features.discounts.utils import generate_offer_data
from xmodule.course_block import COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE # lint-amnesty, pylint: disable=wrong-import-order

Expand Down Expand Up @@ -243,7 +247,7 @@ def get(self, request, *args, **kwargs): # pylint: disable=too-many-statements
show_enrolled = is_enrolled or is_staff
enable_proctored_exams = False
if show_enrolled:
course_blocks = get_course_outline_block_tree(request, course_key_string, request.user)
course_blocks = get_course_outline_block_tree_with_cache(request, course_key_string, request.user)
date_blocks = get_course_date_blocks(course, request.user, request, num_assignments=1)
dates_widget['course_date_blocks'] = [block for block in date_blocks if not isinstance(block, TodaysDate)]

Expand Down Expand Up @@ -278,7 +282,7 @@ def get(self, request, *args, **kwargs): # pylint: disable=too-many-statements
resume_course['url'] = start_block['lms_web_url']

elif allow_public_outline or allow_public or user_is_masquerading:
course_blocks = get_course_outline_block_tree(request, course_key_string, None)
course_blocks = get_course_outline_block_tree_with_cache(request, course_key_string, None)
if allow_public or user_is_masquerading:
handouts_html = get_course_info_section(request, request.user, course, 'handouts')

Expand Down Expand Up @@ -416,7 +420,7 @@ class CourseNavigationBlocksView(RetrieveAPIView):

serializer_class = CourseBlockSerializer
COURSE_BLOCKS_CACHE_KEY_TEMPLATE = (
'course_sidebar_blocks_{course_key_string}_{course_version}_{user_id}_{user_cohort_id}'
'course_sidebar_blocks_{course_key_string}_{course_edited_timestamp}_{user_id}_{user_cohort_id}'
'_{enrollment_mode}_{allow_public}_{allow_public_outline}_{is_masquerading}'
)
COURSE_BLOCKS_CACHE_TIMEOUT = 60 * 60 # 1 hour
Expand Down Expand Up @@ -451,7 +455,7 @@ def get(self, request, *args, **kwargs):

cache_key = self.COURSE_BLOCKS_CACHE_KEY_TEMPLATE.format(
course_key_string=course_key_string,
course_version=str(course.course_version),
course_edited_timestamp=str(course.subtree_edited_on.timestamp()),
user_id=request.user.id,
enrollment_mode=getattr(enrollment, 'mode', ''),
user_cohort_id=getattr(user_cohort, 'id', ''),
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
f'{WAFFLE_FLAG_NAMESPACE}.mfe_courseware_search', __name__
)

# .. toggle_name: courseware.navigation_sidebar_blocks_caching
# .. toggle_name: courseware.disable_navigation_sidebar_blocks_caching
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Disable caching of navigation sidebar blocks on Learning MFE.
Expand Down
11 changes: 11 additions & 0 deletions openedx/features/course_experience/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@


@request_cached()
def get_course_outline_block_tree_with_cache(request, course_id, user=None, allow_start_dates_in_future=False):
"""
Returns the root block of the course outline, with children as blocks.

allow_start_dates_in_future (bool): When True, will allow blocks to be
returned that can bypass the StartDateTransformer's filter to show
blocks with start dates in the future.
NiedielnitsevIvan marked this conversation as resolved.
Show resolved Hide resolved
"""
return get_course_outline_block_tree(request, course_id, user, allow_start_dates_in_future)


def get_course_outline_block_tree(request, course_id, user=None, allow_start_dates_in_future=False): # lint-amnesty, pylint: disable=too-many-statements
"""
Returns the root block of the course outline, with children as blocks.
Expand Down
Loading