Clear cached children when binding an XModuleDescriptor/XBlock to a particular user

This commit is contained in:
Calen Pennington
2015-02-20 13:11:53 -05:00
parent 9379fd2711
commit de23d6defe
7 changed files with 52 additions and 17 deletions

View File

@@ -497,10 +497,8 @@ def get_module_system_for_user(user, field_data_cache,
# rebinds module to a different student. We'll change system, student_data, and scope_ids
module.descriptor.bind_for_student(
inner_system,
LmsFieldData(module.descriptor._field_data, inner_student_data) # pylint: disable=protected-access
)
module.descriptor.scope_ids = (
module.descriptor.scope_ids._replace(user_id=real_user.id) # pylint: disable=protected-access
LmsFieldData(module.descriptor._field_data, inner_student_data), # pylint: disable=protected-access
real_user.id,
)
module.scope_ids = module.descriptor.scope_ids # this is needed b/c NamedTuples are immutable
# now bind the module to the new ModuleSystem instance and vice-versa
@@ -688,8 +686,7 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
request_token=request_token
)
descriptor.bind_for_student(system, field_data) # pylint: disable=protected-access
descriptor.scope_ids = descriptor.scope_ids._replace(user_id=user.id) # pylint: disable=protected-access
descriptor.bind_for_student(system, field_data, user.id) # pylint: disable=protected-access
return descriptor

View File

@@ -921,7 +921,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
location = course_id.make_usage_key('dummy_category', 'dummy_name')
descriptor = Mock(
spec=xblock_class,
_field_data=Mock(spec=FieldData),
_field_data=Mock(spec=FieldData, name='field_data'),
location=location,
static_asset_path=None,
_runtime=Mock(
@@ -931,7 +931,10 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
name='runtime',
),
scope_ids=Mock(spec=ScopeIds),
name='descriptor'
name='descriptor',
_field_data_cache={},
_dirty_fields={},
fields={},
)
descriptor.runtime = CombinedSystem(descriptor._runtime, None) # pylint: disable=protected-access
# Use the xblock_class's bind_for_student method