'Retrieve history of state changes for a given block for a given
student.  We don\'t guarantee that history for many blocks will be fast.
If the specified block doesn\'t exist, raise :class:`~DoesNotExist`.
Arguments:
username: The name of the user whose history should be retrieved.
block_key: The key identifying which xblock history to retrieve.
scope (Scope): The scope to load data from.
Yields:
XBlockUserState entries for each modification to the specified XBlock, from latest
to earliest.'

def get_history(self, username, block_key, scope=Scope.user_state):

    if (scope != Scope.user_state):
        raise ValueError('Only    Scope.user_state    is    supported')
    student_modules = list((student_module for (student_module, usage_id) in self._get_student_modules(username, [block_key])))
    if (len(student_modules) == 0):
        raise self.DoesNotExist()
    history_entries = BaseStudentModuleHistory.get_history(student_modules)
    if (not history_entries):
        raise self.DoesNotExist()
    for history_entry in history_entries:
        state = history_entry.state
        if (state is not None):
            state = json.loads(state)
        if (state == {}):
            state = None
        block_key = history_entry.csm.module_state_key
        block_key = block_key.map_into_course(history_entry.csm.course_id)
        (yield XBlockUserState(username, block_key, state, history_entry.created, scope))
