Skip to content

Commit f87cd38

Browse files
committed
fix: update the write version and add fallback for old cache
1 parent 9037ecf commit f87cd38

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lms/djangoapps/course_blocks/transformers/library_content.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo
5353
5454
Staff users are not to be exempted from item bank pathways.
5555
"""
56-
WRITE_VERSION = 1
56+
WRITE_VERSION = 2
5757
READ_VERSION = 1
5858

5959
@classmethod
@@ -259,10 +259,19 @@ def transform(self, usage_info, block_structure):
259259
to match the order of the selections made and stored in the XBlock 'selected' field.
260260
"""
261261
for block_key in block_structure:
262-
# Check if this block was marked as an ItemBankMixin block by ContentLibraryTransformer
263-
if not block_structure.get_transformer_block_field(
264-
block_key, ContentLibraryTransformer, 'is_item_bank_block'
265-
):
262+
# Try to read from cache first (collected by ContentLibraryTransformer)
263+
is_item_bank = block_structure.get_transformer_block_field(
264+
block_key,
265+
ContentLibraryTransformer,
266+
'is_item_bank_block'
267+
)
268+
269+
# Fallback for old cache that doesn't have the field
270+
if is_item_bank is None:
271+
block_class = _get_block_class(block_key.block_type)
272+
is_item_bank = block_class and issubclass(block_class, ItemBankMixin)
273+
274+
if not is_item_bank:
266275
continue
267276

268277
library_children = block_structure.get_children(block_key)

0 commit comments

Comments
 (0)