def __init__( self, handler_url, # type: Callable[[UsageKey, str, Union[int, ANONYMOUS_USER]], str] student_data_mode, # type: Union[STUDENT_DATA_EPHEMERAL, STUDENT_DATA_PERSISTED] runtime_class, # type: XBlockRuntime ): """ args: handler_url: A method to get URLs to call XBlock handlers. It must implement this signature: handler_url( usage_key: UsageKey, handler_name: str, user_id: Union[int, str], ) student_data_mode: Specifies whether student data should be kept in a temporary in-memory store (e.g. Studio) or persisted forever in the database. runtime_class: What runtime to use, e.g. BlockstoreXBlockRuntime """ self.handler_url = handler_url self.id_reader = OpaqueKeyReader() self.id_generator = MemoryIdManager( ) # We don't really use id_generator until we need to support asides self.runtime_class = runtime_class self.authored_data_store = BlockstoreFieldData() self.children_data_store = BlockstoreChildrenData( self.authored_data_store) assert student_data_mode in (self.STUDENT_DATA_EPHEMERAL, self.STUDENT_DATA_PERSISTED) self.student_data_mode = student_data_mode self._error_trackers = {}
def get_runtime_system_params(self): """ Get the XBlockRuntimeSystem parameters appropriate for viewing and/or editing XBlock content in Studio """ return dict( authored_data_store=BlockstoreFieldData(), student_data_store=KvsFieldData(kvs=DictKeyValueStore()), )