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

EDUCATOR-3 Check for course before using it.
This commit is contained in:
Attiya Ishaque
2017-05-30 13:44:42 +05:00
committed by GitHub
3 changed files with 8 additions and 4 deletions

View File

@@ -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

View File

@@ -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">

View File

@@ -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" />