Extract common functionality to xblock-utils

@antoviaque Will `publish_event_from_dict` be fine? I would like to merge in these changes before https://github.com/open-craft/xblock-mentoring/pull/2, as there's quite some overlap.