Commit d7e44108 by Ned Batchelder

Adjust parameters to construct_xblock_from_class to match XBlock repo.

parent e73bc906
......@@ -105,10 +105,10 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor):
})
return system.construct_xblock_from_class(
cls,
field_data,
# The error module doesn't use scoped data, and thus doesn't need
# real scope keys
ScopeIds('error', None, location, location)
ScopeIds('error', None, location, location),
field_data,
)
def get_context(self):
......
......@@ -193,7 +193,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
field_data = DbModel(kvs)
scope_ids = ScopeIds(None, category, location, location)
module = self.construct_xblock_from_class(class_, field_data, scope_ids)
module = self.construct_xblock_from_class(class_, scope_ids, field_data)
if self.cached_metadata is not None:
# parent container pointers don't differentiate between draft and non-draft
# so when we do the lookup, we should do so with a non-draft location
......@@ -621,12 +621,11 @@ class MongoModuleStore(ModuleStoreBase):
dbmodel = self._create_new_field_data(location.category, location, definition_data, metadata)
xmodule = system.construct_xblock_from_class(
xblock_class,
dbmodel,
# We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet,
# so we use the location for both.
ScopeIds(None, location.category, location, location)
ScopeIds(None, location.category, location, location),
dbmodel,
)
# decache any pending field settings from init
xmodule.save()
......
......@@ -111,8 +111,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
try:
module = self.construct_xblock_from_class(
class_,
ScopeIds(None, json_data.get('category'), definition_id, block_locator),
field_data,
ScopeIds(None, json_data.get('category'), definition_id, block_locator)
)
except Exception:
log.warning("Failed to load descriptor", exc_info=True)
......
......@@ -477,11 +477,11 @@ class XMLModuleStore(ModuleStoreBase):
loc = Location('i4x', course_descriptor.location.org, course_descriptor.location.course, category, slug)
module = system.construct_xblock_from_class(
HtmlDescriptor,
DictFieldData({'data': html, 'location': loc, 'category': category}),
# We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet,
# so we use the location for both
ScopeIds(None, category, loc, loc),
DictFieldData({'data': html, 'location': loc, 'category': category}),
)
# VS[compat]:
# Hack because we need to pull in the 'display_name' for static tabs (because we need to edit them)
......
......@@ -46,8 +46,8 @@ class TabsEditingDescriptorTestCase(unittest.TestCase):
TabsEditingDescriptor.tabs = self.tabs
self.descriptor = system.construct_xblock_from_class(
TabsEditingDescriptor,
field_data=DictFieldData({}),
scope_ids=ScopeIds(None, None, None, None),
field_data=DictFieldData({}),
)
def test_get_css(self):
......
......@@ -133,8 +133,8 @@ class VideoDescriptorTest(unittest.TestCase):
system = get_test_descriptor_system()
self.descriptor = system.construct_xblock_from_class(
VideoDescriptor,
field_data=DictFieldData({}),
scope_ids=ScopeIds(None, None, None, None),
field_data=DictFieldData({}),
)
def test_get_context(self):
......
......@@ -87,8 +87,8 @@ class TestXBlockWrapper(object):
runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime.construct_xblock_from_class(
descriptor_cls,
ScopeIds(None, descriptor_cls.__name__, location, location),
DictFieldData({}),
ScopeIds(None, descriptor_cls.__name__, location, location)
)
def leaf_module(self, descriptor_cls):
......@@ -109,10 +109,10 @@ class TestXBlockWrapper(object):
runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime.construct_xblock_from_class(
descriptor_cls,
ScopeIds(None, descriptor_cls.__name__, location, location),
DictFieldData({
'children': range(3)
}),
ScopeIds(None, descriptor_cls.__name__, location, location)
)
def container_module(self, descriptor_cls, depth):
......
......@@ -166,8 +166,8 @@ class EditableMetadataFieldsTest(unittest.TestCase):
runtime = get_test_descriptor_system()
return runtime.construct_xblock_from_class(
XmlDescriptor,
scope_ids=Mock(),
field_data=field_data,
scope_ids=Mock()
).editable_metadata_fields
def get_descriptor(self, field_data):
......
......@@ -247,12 +247,11 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor
field_data = DbModel(kvs)
video = system.construct_xblock_from_class(
cls,
field_data,
# We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet,
# so we use the location for both
ScopeIds(None, location.category, location, location)
ScopeIds(None, location.category, location, location),
field_data,
)
return video
......
......@@ -502,8 +502,8 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
module = system.construct_xblock_from_class(
self.module_class,
descriptor=self,
field_data=system.xmodule_field_data(self),
scope_ids=self.scope_ids,
field_data=system.xmodule_field_data(self),
)
module.save()
return module
......
......@@ -339,12 +339,11 @@ class XmlDescriptor(XModuleDescriptor):
return system.construct_xblock_from_class(
cls,
field_data,
# We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet,
# so we use the location for both
ScopeIds(None, location.category, location, location)
ScopeIds(None, location.category, location, location),
field_data,
)
@classmethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment