'Update values of xfields, that were changed by student.'

def handle_ajax(self, dispatch, data):

    accepted_keys = ['speed', 'saved_video_position', 'transcript_language', 'transcript_download_format', 'youtube_is_available', 'bumper_last_view_date', 'bumper_do_not_show_again']
    conversions = {'speed': json.loads, 'saved_video_position': RelativeTime.isotime_to_timedelta, 'youtube_is_available': json.loads}
    if (dispatch == 'save_user_state'):
        for key in data:
            if (key in accepted_keys):
                if (key in conversions):
                    value = conversions[key](data[key])
                else:
                    value = data[key]
                if (key == 'bumper_last_view_date'):
                    value = datetime.utcnow()
                setattr(self, key, value)
                if (key == 'speed'):
                    self.global_speed = self.speed
        return json.dumps({'success': True})
    log.debug(u'GET    {0}'.format(data))
    log.debug(u'DISPATCH    {0}'.format(dispatch))
    raise NotFoundError('Unexpected    dispatch    type')
