diff --git a/cms/djangoapps/contentstore/tests/factories.py b/cms/djangoapps/contentstore/tests/factories.py index 3274477098..cb9f451d38 100644 --- a/cms/djangoapps/contentstore/tests/factories.py +++ b/cms/djangoapps/contentstore/tests/factories.py @@ -73,6 +73,10 @@ class XModuleItemFactory(Factory): @classmethod def _create(cls, target_class, *args, **kwargs): + """ + kwargs must include parent_location, template. Can contain display_name + target_class is ignored + """ DETACHED_CATEGORIES = ['about', 'static_tab', 'course_info'] diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index b3f13de998..a8bf5e82a0 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -22,6 +22,8 @@ from xmodule.modulestore.django import modulestore from xmodule.contentstore.django import contentstore from xmodule.course_module import CourseDescriptor from xmodule.modulestore.xml_exporter import export_to_xml +from cms.djangoapps.contentstore.utils import get_modulestore +from xmodule.capa_module import CapaDescriptor def parse_json(response): """Parse response, which is assumed to be json""" @@ -438,13 +440,23 @@ class ContentStoreTest(TestCase): self.assertContains(resp, '/c4x/edX/full/asset/handouts_schematic_tutorial.pdf') + def test_capa_module(self): + """Test that a problem w/ markdown has markdown and uses the right html etc""" + CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course') + problem_data = { + 'parent_location' : 'i4x://MITx/999/course/Robot_Super_Course', + 'template' : 'i4x://edx/templates/problem/Empty' + } + resp = self.client.post(reverse('clone_item'), problem_data) - - - - - - - + self.assertEqual(resp.status_code, 200) + payload = parse_json(resp) + problem_loc = payload['id'] + problem = get_modulestore(problem_loc).get_item(problem_loc) + # should be a CapaDescriptor + self.assertIsInstance(problem, CapaDescriptor, "New problem is not a CapaDescriptor") + context = problem.get_context() + self.assertIn('markdown', context, "markdown is missing") + self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") \ No newline at end of file diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index d828993e34..19d74024c7 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -271,7 +271,8 @@ def edit_unit(request, location): component_templates[template.location.category].append(( template.display_name, template.location.url(), - 'markdown' in template.metadata + 'markdown' in template.metadata, + template.location.name == 'Empty' )) components = [ diff --git a/cms/static/coffee/src/views/module_edit.coffee b/cms/static/coffee/src/views/module_edit.coffee index 0617b01bb4..b1157f713e 100644 --- a/cms/static/coffee/src/views/module_edit.coffee +++ b/cms/static/coffee/src/views/module_edit.coffee @@ -55,7 +55,7 @@ class CMS.Views.ModuleEdit extends Backbone.View clickSaveButton: (event) => event.preventDefault() data = @module.save() - data.metadata = @metadata() + data.metadata = _.extend(data.metadata, @metadata()) $modalCover.hide() @model.save(data).done( => # # showToastMessage("Your changes have been saved.", null, 3) diff --git a/cms/templates/unit.html b/cms/templates/unit.html index 40dfd65381..f261be62fa 100644 --- a/cms/templates/unit.html +++ b/cms/templates/unit.html @@ -152,13 +152,16 @@ % for type, templates in sorted(component_templates.items()):