Commit 44074f30 by Sanford Student

move course version repopulation to runtime layer

for TNL-6065
parent a7f47208
......@@ -955,7 +955,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
item = system.load_item(location, for_parent=for_parent)
# TODO Once PLAT-1055 is implemented, we can remove the following line
# TODO Once TNL-5092 is implemented, we can remove the following line
# of code. Until then, set the course_version field on the block to be
# consistent with the Split modulestore. Since Mongo modulestore doesn't
# maintain course versions set it to None.
......
......@@ -131,6 +131,13 @@ class CachingDescriptorSystem(MakoDescriptorSystem, EditInfoRuntimeMixin):
class_ = self.load_block_type(block_data.block_type)
block = self.xblock_from_json(class_, course_key, block_key, block_data, course_entry_override, **kwargs)
# TODO Once TNL-5092 is implemented, we can expose the course version
# information within the key identifier of the block. Until then, set
# the course_version as a field on the returned block so higher layers
# can use it when needed.
block.course_version = version_guid
self.modulestore.cache_block(course_key, version_guid, block_key, block)
return block
......
......@@ -779,15 +779,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
self._add_cache(course_entry.structure['_id'], runtime)
self.cache_items(runtime, block_keys, course_entry.course_key, depth, lazy)
blocks = [runtime.load_item(block_key, course_entry, **kwargs) for block_key in block_keys]
# TODO Once PLAT-1055 is implemented, we can expose the course version
# information within the key identifier of the block. Until then, set
# the course_version as a field on each returned block so higher layers
# can use it when needed.
for block in blocks:
block.course_version = course_entry.course_key.version_guid
return blocks
return [runtime.load_item(block_key, course_entry, **kwargs) for block_key in block_keys]
def _get_cache(self, course_version_guid):
"""
......
......@@ -454,6 +454,10 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
self.assertEquals(len(blocks), 7)
for block in blocks:
self.assertEquals(block.course_version, course_version)
# ensure that when the block is retrieved from the runtime cache,
# the course version is still present
cached_block = course.runtime.load_item(block.location)
self.assertEqual(cached_block.course_version, block.course_version)
@ddt.data((ModuleStoreEnum.Type.split, 2, False), (ModuleStoreEnum.Type.mongo, 3, True))
@ddt.unpack
......
......@@ -352,6 +352,10 @@ class GradesTransformerTestCase(CourseStructureTestCase):
blocks = self.build_course_with_problems()
block_structure = get_course_blocks(self.student, blocks[u'course'].location, self.transformers)
self.assertIsNotNone(block_structure.get_xblock_field(blocks[u'course'].location, u'course_version'))
self.assertEqual(
block_structure.get_xblock_field(blocks[u'problem'].location, u'course_version'),
block_structure.get_xblock_field(blocks[u'course'].location, u'course_version')
)
def test_grading_policy_collected(self):
# the calculated hash of the original and updated grading policies of the test course
......
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