This seems like it overlaps with https://github.com/edx/edx-platform/pull/3651 (I commented on the comment in this function in that PR too).