From 7f3e4cb8106b01e40fc1cf0afa52373c4fa5c993 Mon Sep 17 00:00:00 2001 From: attiyaishaque Date: Thu, 25 May 2017 15:40:29 +0500 Subject: [PATCH] EDUCATOR-3 Check for course before using it. --- cms/djangoapps/contentstore/proctoring.py | 5 ++++- lms/templates/courseware/course_navigation.html | 5 +++-- lms/templates/courseware/courseware.html | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/proctoring.py b/cms/djangoapps/contentstore/proctoring.py index 55b31d95c3..4731e18946 100644 --- a/cms/djangoapps/contentstore/proctoring.py +++ b/cms/djangoapps/contentstore/proctoring.py @@ -7,7 +7,7 @@ import logging from django.conf import settings from xmodule.modulestore.django import modulestore - +from xmodule.modulestore.exceptions import ItemNotFoundError from contentstore.views.helpers import is_item_in_course_tree from edx_proctoring.api import ( @@ -40,6 +40,9 @@ def register_special_exams(course_key): return course = modulestore().get_course(course_key) + if course is None: + raise ItemNotFoundError("Course {} does not exist", unicode(course_key)) + if not course.enable_proctored_exams and not course.enable_timed_exams: # likewise if course does not have these features turned on # then quickly exit diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index a77fe168bb..273ecb4837 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -14,10 +14,11 @@ if active_page is None and active_page_context is not UNDEFINED: # If active_page is not passed in as an argument, it may be in the context as active_page_context active_page = active_page_context -include_special_exams = settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and (course.enable_proctored_exams or course.enable_timed_exams) +if course is not None: + include_special_exams = settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and (course.enable_proctored_exams or course.enable_timed_exams) %> -% if include_special_exams: +% if include_special_exams is not UNDEFINED and include_special_exams: <%static:js group='proctoring'/> % for template_name in ["proctored-exam-status"]: