Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _user_state_key(self):
return xblock.runtime.KeyValueStore.Key(
scope=xblock.fields.Scope.user_state, user_id='123',
block_scope_id='456', field_name='my_field')
if block_scope == BlockScope.ALL:
block_id = None
elif block_scope == BlockScope.USAGE:
block_id = block.scope_ids.usage_id
elif block_scope == BlockScope.DEFINITION:
block_id = block.scope_ids.def_id
elif block_scope == BlockScope.TYPE:
block_id = block.scope_ids.block_type
if field.scope.user == UserScope.ONE:
user_id = block.scope_ids.user_id
else:
user_id = None
key = KeyValueStore.Key(
scope=field.scope,
user_id=user_id,
block_scope_id=block_id,
field_name=name,
block_family=block.entry_point,
)
return key