'Bind a module (part of self.course) so we can access student-specific data.'

def _bind_course_module(self, module):

    module_system = get_test_system(course_id=module.location.course_key)
    module_system.descriptor_runtime = module.runtime._descriptor_system
    module_system._services['library_tools'] = self.tools
    def get_module(descriptor):
        'Mocks    module_system    get_module    function'
        sub_module_system = get_test_system(course_id=module.location.course_key)
        sub_module_system.get_module = get_module
        sub_module_system.descriptor_runtime = descriptor._runtime
        descriptor.bind_for_student(sub_module_system, self.user_id)
        return descriptor
    module_system.get_module = get_module
    module.xmodule_runtime = module_system
