Fix several issues with course deletion

This patch fixes three issues with course deletion, two new and one
longstanding.

Change-Id: I6a88a86097afbc55c4258dc2d73d273fd9fbcf3c
(cherry picked from commit bec2cfe1d360480e5836362bb3e1a7bf506771d8)