diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index 1162125300..2028f17dc1 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -1513,6 +1513,10 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): user_id, parent_usage_key.course_key, block_type, block_id=block_id, fields=fields, **kwargs) + # skip attach to parent if xblock has 'detached' tag + if 'detached' in xblock._class_tags: # pylint: disable=protected-access + return xblock + # don't version the structure as create_item handled that already. new_structure = self._lookup_course(xblock.location.course_key).structure diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index ef19575d6f..a392e2d05d 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -840,6 +840,27 @@ class TestMixedModuleStore(CourseComparisonTest): published_courses = self.store.get_courses(remove_branch=True) self.assertEquals([c.id for c in draft_courses], [c.id for c in published_courses]) + @ddt.data('draft', 'split') + def test_create_child_detached_tabs(self, default_ms): + """ + test 'create_child' method with a detached category ('static_tab') + to check that new static tab is not a direct child of the course + """ + self.initdb(default_ms) + mongo_course = self.store.get_course(self.course_locations[self.MONGO_COURSEID].course_key) + self.assertEqual(len(mongo_course.children), 1) + + # create a static tab of the course + self.store.create_child( + self.user_id, + self.course.location, + 'static_tab' + ) + + # now check that the course has same number of children + mongo_course = self.store.get_course(self.course_locations[self.MONGO_COURSEID].course_key) + self.assertEqual(len(mongo_course.children), 1) + def test_xml_get_courses(self): """ Test that the xml modulestore only loaded the courses from the maps.