Commit 481eac7f by Chris Dodge

address PR feedback

parent 7b4388ba
...@@ -627,8 +627,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -627,8 +627,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# get a vertical (and components in it) to put into 'draft' # get a vertical (and components in it) to put into 'draft'
# this is to assert that draft content is also cloned over # this is to assert that draft content is also cloned over
vertical = module_store.get_item(Location(['i4x', 'edX', 'toy', vertical = module_store.get_instance(source_course_id, Location([
'vertical', 'vertical_test', None]), depth=1) source_location.tag, source_location.org, source_location.course, 'vertical', 'vertical_test', None]), depth=1)
draft_store.convert_to_draft(vertical.location) draft_store.convert_to_draft(vertical.location)
for child in vertical.get_children(): for child in vertical.get_children():
...@@ -649,24 +649,23 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -649,24 +649,23 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# first assert that all draft content got cloned as well # first assert that all draft content got cloned as well
items = module_store.get_items(Location([source_location.tag, source_location.org, source_location.course, None, None, 'draft'])) items = module_store.get_items(Location([source_location.tag, source_location.org, source_location.course, None, None, 'draft']))
self.assertGreater(len(items), 0) self.assertGreater(len(items), 0)
clone_items = module_store.get_items(Location([source_location.tag, source_location.org, source_location.course, None, None, 'draft'])) clone_items = module_store.get_items(Location([dest_location.tag, dest_location.org, dest_location.course, None, None, 'draft']))
self.assertGreater(len(clone_items), 0) self.assertGreater(len(clone_items), 0)
self.assertEqual(len(items), len(clone_items)) self.assertEqual(len(items), len(clone_items))
# now loop through all the units in the course and verify that the clone can render them, which # now loop through all the units in the course and verify that the clone can render them, which
# means the objects are at least present # means the objects are at least present
items = module_store.get_items(Location(['i4x', 'edX', 'toy', None, None])) items = module_store.get_items(Location([source_location.tag, source_location.org, source_location.course, None, None]))
self.assertGreater(len(items), 0) self.assertGreater(len(items), 0)
clone_items = module_store.get_items(Location(['i4x', 'MITx', '999', None, None])) clone_items = module_store.get_items(Location([dest_location.tag, dest_location.org, dest_location.course, None, None]))
self.assertGreater(len(clone_items), 0) self.assertGreater(len(clone_items), 0)
#self.assertEqual(len(items), len(clone_items))
for descriptor in items: for descriptor in items:
source_item = module_store.get_instance(source_course_id, descriptor.location) source_item = module_store.get_instance(source_course_id, descriptor.location)
if descriptor.location.category == 'course': if descriptor.location.category == 'course':
new_loc = descriptor.location.replace(org='MITx', course='999', name='2013_Spring') new_loc = descriptor.location.replace(org=dest_location.org, course=dest_location.course, name='2013_Spring')
else: else:
new_loc = descriptor.location.replace(org='MITx', course='999') new_loc = descriptor.location.replace(org=dest_location.org, course=dest_location.course)
print "Checking {0} should now also be at {1}".format(descriptor.location.url(), new_loc.url()) print "Checking {0} should now also be at {1}".format(descriptor.location.url(), new_loc.url())
lookup_item = module_store.get_item(new_loc) lookup_item = module_store.get_item(new_loc)
......
...@@ -11,16 +11,17 @@ def _clone_modules(modulestore, modules, dest_location): ...@@ -11,16 +11,17 @@ def _clone_modules(modulestore, modules, dest_location):
original_loc = Location(module.location) original_loc = Location(module.location)
if original_loc.category != 'course': if original_loc.category != 'course':
module.location = module.location._replace(tag=dest_location.tag, org=dest_location.org, module.location = module.location._replace(
course=dest_location.course) tag=dest_location.tag, org=dest_location.org, course=dest_location.course)
else: else:
# on the course module we also have to update the module name # on the course module we also have to update the module name
module.location = module.location._replace(tag=dest_location.tag, org=dest_location.org, module.location = module.location._replace(
course=dest_location.course, name=dest_location.name) tag=dest_location.tag, org=dest_location.org, course=dest_location.course, name=dest_location.name)
print "Cloning module {0} to {1}....".format(original_loc, module.location) print "Cloning module {0} to {1}....".format(original_loc, module.location)
modulestore.update_item(module.location, module._model_data._kvs._data) # NOTE: usage of the the internal module.xblock_kvs._data does not include any 'default' values for the fields
modulestore.update_item(module.location, module.xblock_kvs._data)
# repoint children # repoint children
if module.has_children: if module.has_children:
......
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