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.
@waheedahmed You can also do `course_id = kwargs.get("course_id") or args[0]`. But is the first case really necessary?