Fixed 500 error on views with incomplete course id in url.

LMS-11217

Added try except in views to catch InvalidKeyError and raised Http404 when an incomplete course id is in url.

Added unit test.
`args[0]` might not always be defined.