MDL-41185 fix url in course_viewed event after course deleted

Includes a minor fix for course invalidation after deleting of course,
this improvement should not affect normal execution, that is why
it was not backported.