From ea579bf54b9ebb7cccba9a4c72bf4d31bee3d52f Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Mon, 29 Dec 2014 20:01:36 -0800 Subject: [PATCH] Workaround an issue with capa modules --- .../xmodule/xmodule/modulestore/split_mongo/split.py | 10 ++++++++++ .../xmodule/modulestore/tests/test_libraries.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index a0d9fea0cd..7fa26e9d8b 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -2182,6 +2182,16 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): existing_block_info = dest_structure['blocks'].get(new_block_key, {}) # Inherit the Scope.settings values from 'fields' to 'defaults' new_block_info['defaults'] = new_block_info['fields'] + + # + # CAPA modules store their 'markdown' value (an alternate representation of their content) in Scope.settings rather than Scope.content :-/ + # markdown is a field that really should not be overridable - it fundamentally changes the content. + # capa modules also use a custom editor that always saves their markdown field to the metadata, even if it hasn't changed, which breaks our override system. + # So until capa modules are fixed, we special-case them and remove their markdown fields, forcing the inherited version to use XML only. + if usage_key.block_type == 'problem' and 'markdown' in new_block_info['defaults']: + del new_block_info['defaults']['markdown'] + # + new_block_info['fields'] = existing_block_info.get('fields', {}) # Preserve any existing overrides if 'children' in new_block_info['defaults']: del new_block_info['defaults']['children'] # Will be set later diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py b/common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py index 323fd23301..fd9e941784 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py @@ -274,6 +274,10 @@ class TestSplitCopyTemplate(MixedSplitTestCase): problem_block_course = self.store.get_item(vertical_block_course.children[0]) self.assertEqual(problem_block_course.display_name, problem_library_display_name) + # Check that when capa modules are copied, their "markdown" fields (Scope.settings) are removed. (See note in split.py:copy_from_template()) + self.assertIsNotNone(problem_block.markdown) + self.assertIsNone(problem_block_course.markdown) + # Override the display_name and weight: new_display_name = "The Trouble with Tribbles" new_weight = 20