refactor: replace xmodule.load_item calls with get_block

This commit is contained in:
Arunmozhi
2022-12-05 16:10:05 +05:30
committed by Agrendalath
parent 851eb65d53
commit 59757ee52d
5 changed files with 6 additions and 6 deletions

View File

@@ -326,7 +326,7 @@ class ConditionalBlock(
descriptors = []
for location in self.sources_list:
try:
descriptor = self.system.load_item(location)
descriptor = self.system.get_block(location)
descriptors.append(descriptor)
except ItemNotFoundError:
msg = "Invalid module by location."

View File

@@ -824,7 +824,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
system = using_descriptor_system
system.module_data.update(data_cache)
item = system.load_item(location, for_parent=for_parent)
item = system.get_block(location, for_parent=for_parent)
# TODO Once TNL-5092 is implemented, we can remove the following line
# of code. Until then, set the course_version field on the block to be

View File

@@ -448,7 +448,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
assert block.course_version == course_version
# ensure that when the block is retrieved from the runtime cache,
# the course version is still present
cached_block = course.runtime.load_item(block.location)
cached_block = course.runtime.get_block(block.location)
assert cached_block.course_version == block.course_version
@ddt.data((ModuleStoreEnum.Type.split, 2, False), (ModuleStoreEnum.Type.mongo, 3, True))

View File

@@ -639,7 +639,7 @@ class XMLModuleStore(ModuleStoreReadBase):
else:
try:
# get and update data field in xblock runtime
module = system.load_item(loc)
module = system.get_block(loc)
for key, value in data_content.items():
setattr(module, key, value)
module.save()
@@ -653,7 +653,7 @@ class XMLModuleStore(ModuleStoreReadBase):
# html file with html data content
html = f.read()
try:
module = system.load_item(loc)
module = system.get_block(loc)
module.data = html
module.save()
except ItemNotFoundError:

View File

@@ -111,7 +111,7 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method
# cdodge: look up the template as a module
template_loc = self.location.replace(category='custom_tag_template', name=template_name)
template_block = system.load_item(template_loc)
template_block = system.get_block(template_loc)
template_block_data = template_block.data
template = Template(template_block_data)
return template.safe_substitute(params)