Commit f91a5f0e by Calen Pennington

Merge pull request #1273 from MITx/fix/cdodge/filesystem-xml-fixes

Fix/cdodge/filesystem xml fixes
parents c9c9f7e5 9f732949
...@@ -350,6 +350,21 @@ class ContentStoreTest(TestCase): ...@@ -350,6 +350,21 @@ class ContentStoreTest(TestCase):
def test_edit_unit_full(self): def test_edit_unit_full(self):
self.check_edit_unit('full') self.check_edit_unit('full')
def test_about_overrides(self):
'''
This test case verifies that a course can use specialized override for about data, e.g. /about/Fall_2012/effort.html
while there is a base definition in /about/effort.html
'''
import_from_xml(modulestore(), 'common/test/data/', ['full'])
ms = modulestore('direct')
effort = ms.get_item(Location(['i4x','edX','full','about','effort', None]))
self.assertEqual(effort.definition['data'],'6 hours')
# this one should be in a non-override folder
effort = ms.get_item(Location(['i4x','edX','full','about','end_date', None]))
self.assertEqual(effort.definition['data'],'TBD')
def test_clone_course(self): def test_clone_course(self):
import_from_xml(modulestore(), 'common/test/data/', ['full']) import_from_xml(modulestore(), 'common/test/data/', ['full'])
......
...@@ -444,14 +444,20 @@ class XMLModuleStore(ModuleStoreBase): ...@@ -444,14 +444,20 @@ class XMLModuleStore(ModuleStoreBase):
log.debug('========> Done with course import from {0}'.format(course_dir)) log.debug('========> Done with course import from {0}'.format(course_dir))
return course_descriptor return course_descriptor
def load_extra_content(self, system, course_descriptor, category, base_dir, course_dir, url_name): def load_extra_content(self, system, course_descriptor, category, base_dir, course_dir, url_name):
if url_name:
path = base_dir / url_name
if not os.path.exists(path): self._load_extra_content(system, course_descriptor, category, base_dir, course_dir)
path = base_dir
# then look in a override folder based on the course run
if os.path.isdir(base_dir / url_name):
self._load_extra_content(system, course_descriptor, category, base_dir / url_name, course_dir)
def _load_extra_content(self, system, course_descriptor, category, path, course_dir):
for filepath in glob.glob(path/ '*'): for filepath in glob.glob(path/ '*'):
if not os.path.isdir(filepath):
with open(filepath) as f: with open(filepath) as f:
try: try:
html = f.read().decode('utf-8') html = f.read().decode('utf-8')
......
12 hours
\ No newline at end of file
TBD
\ No newline at end of file
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