From 68a8587ed2632681d4ffc45cdad579630b9e810f Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 21 Feb 2013 11:02:47 -0500 Subject: [PATCH 1/3] don't serialize weight out as an int - use a string. The code in capa-module.py expects a string and tries to convert to a float. So this impedence mismatch is causing a crash on import when importing empty strings for 'weight' or 'attempts' --- common/lib/xmodule/xmodule/xml_module.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/xml_module.py b/common/lib/xmodule/xmodule/xml_module.py index 64c3aabbcc..773531c528 100644 --- a/common/lib/xmodule/xmodule/xml_module.py +++ b/common/lib/xmodule/xmodule/xml_module.py @@ -128,8 +128,7 @@ class XmlDescriptor(XModuleDescriptor): 'graded': bool_map, 'hide_progress_tab': bool_map, 'allow_anonymous': bool_map, - 'allow_anonymous_to_peers': bool_map, - 'weight': int_map + 'allow_anonymous_to_peers': bool_map } From a7f6545cbc81d37e72eaddba8fde58b53f88858e Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 21 Feb 2013 11:22:20 -0500 Subject: [PATCH 2/3] add unit test --- .../contentstore/tests/test_contentstore.py | 11 +++++++++++ common/test/data/simple/course.xml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index b79d86b52f..f2a0b7b606 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -421,6 +421,17 @@ class ContentStoreTest(ModuleStoreTestCase): self.assertIn('markdown', problem.metadata, "markdown is missing from metadata") self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") + def test_import_metadata_with_attempts_empty_string(self): + import_from_xml(modulestore(), 'common/test/data/', ['simple']) + ms = modulestore('direct') + asserted = False + try: + effort = ms.get_item(Location(['i4x', 'edX', 'simple', 'problem', 'ps01-simple', None])) + except ItemNotFoundError: + asserted = True + + # make sure we found the item (e.g. it didn't error while loading) + self.assertFalse(asserted) class TemplateTestCase(ModuleStoreTestCase): diff --git a/common/test/data/simple/course.xml b/common/test/data/simple/course.xml index 86dc8df45c..433c9bb01b 100644 --- a/common/test/data/simple/course.xml +++ b/common/test/data/simple/course.xml @@ -15,7 +15,7 @@
- +