Commit bbf10c11 by Attiya Ishaque Committed by GitHub

Merge pull request #15189 from edx/ai/EDUCATOR-3-resolve-NoneType-object

EDUCATOR-3 Check for course before using it.
parents 74f9858b 7f3e4cb8
......@@ -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
......
......@@ -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"]:
<script type="text/template" id="${template_name}-tpl">
......
......@@ -45,7 +45,7 @@ from openedx.features.course_experience import UNIFIED_COURSE_VIEW_FLAG
% endfor
% endif
% if include_special_exams:
% if include_special_exams is not UNDEFINED and include_special_exams:
% for template_name in ["proctored-exam-status"]:
<script type="text/template" id="${template_name}-tpl">
<%static:include path="courseware/${template_name}.underscore" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment