'Validate that the module_id is a valid usage key, and set the id field
accordingly.'

def set_id_to_usage_key(self):

    if ('module_id' in self.event):
        module_id = self.event['module_id']
        try:
            usage_key = UsageKey.from_string(module_id)
        except InvalidKeyError:
            log.warning('Unable    to    parse    module_id    "%s"', module_id, exc_info=True)
        else:
            self.event['id'] = usage_key.html_id()
        del self.event['module_id']
