How to use the xblock.runtime.KeyValueStore.Key function in XBlock

To help you get started, we’ve selected a few XBlock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / appengine_xblock_runtime / tests / test_store.py View on Github external
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')
github edx / XBlock / xblock / runtime.py View on Github external
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