From 0388ded8067a46e1235b5fcbfcda2662dddea8c0 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Fri, 20 Oct 2023 14:42:27 -0500 Subject: [PATCH] feat: allow to prefetch xblock aside fields --- lms/djangoapps/courseware/model_data.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/model_data.py b/lms/djangoapps/courseware/model_data.py index 59fcc725ed36..54b7c6bec7c4 100644 --- a/lms/djangoapps/courseware/model_data.py +++ b/lms/djangoapps/courseware/model_data.py @@ -784,7 +784,18 @@ def _fields_to_cache(self, blocks): for block in blocks: for field in block.fields.values(): scope_map[field.scope].add(field) - return scope_map + + try: + block = blocks[0] + from openedx.core.lib.xblock_utils import get_aside_from_xblock # pylint: disable=import-outside-toplevel + for aside in self.asides: + xblock_aside = get_aside_from_xblock(block, aside) + for field in xblock_aside.fields.values(): + scope_map[field.scope].add(field) + return scope_map + except IndexError: + # No blocks to cache + return scope_map def get(self, key): """