From e19fa2c46fc9f24dc01939b5a5f94fa45f698315 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 14 Aug 2015 14:27:55 -0400 Subject: [PATCH] only include JS when feature flag is on and the course has proctoring enabled --- .../courseware/tests/test_navigation.py | 44 +++++++++++++++++++ .../courseware/course_navigation.html | 2 +- requirements/edx/github.txt | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_navigation.py b/lms/djangoapps/courseware/tests/test_navigation.py index 492b94460b..ec8b15ff5d 100644 --- a/lms/djangoapps/courseware/tests/test_navigation.py +++ b/lms/djangoapps/courseware/tests/test_navigation.py @@ -2,6 +2,7 @@ This test file will run through some LMS test scenarios regarding access and navigation of the LMS """ import time +from mock import patch from nose.plugins.attrib import attr from django.conf import settings @@ -12,6 +13,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase from courseware.tests.factories import GlobalStaffFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.django import modulestore @attr('shard_1') @@ -266,3 +268,45 @@ class TestNavigation(ModuleStoreTestCase, LoginEnrollmentTestCase): kwargs={'course_id': test_course_id} ) self.assert_request_status_code(302, url) + + def test_proctoring_js_includes(self): + """ + Make sure that proctoring JS does not get included on + courseware pages if either the FEATURE flag is turned off + or the course is not proctored enabled + """ + + email, password = self.STUDENT_INFO[0] + self.login(email, password) + self.enroll(self.test_course, True) + + test_course_id = self.test_course.id.to_deprecated_string() + + with patch.dict(settings.FEATURES, {'ENABLE_PROCTORED_EXAMS': False}): + url = reverse( + 'courseware', + kwargs={'course_id': test_course_id} + ) + resp = self.client.get(url) + + self.assertNotContains(resp, '/static/js/lms-proctoring.js') + + with patch.dict(settings.FEATURES, {'ENABLE_PROCTORED_EXAMS': True}): + url = reverse( + 'courseware', + kwargs={'course_id': test_course_id} + ) + resp = self.client.get(url) + + self.assertNotContains(resp, '/static/js/lms-proctoring.js') + + # now set up a course which is proctored enabled + + self.test_course.enable_proctored_exams = True + self.test_course.save() + + modulestore().update_item(self.test_course, self.user.id) + + resp = self.client.get(url) + + self.assertContains(resp, '/static/js/lms-proctoring.js') diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 7f812a140b..691b94b57b 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -33,9 +33,9 @@ specific_student_selected = selected(not staff_selected and masquerade.user_name student_selected = selected(not staff_selected and not specific_student_selected and not masquerade_group_id) include_proctoring = settings.FEATURES.get('ENABLE_PROCTORED_EXAMS', False) and course.enable_proctored_exams %> -<%static:js group='proctoring'/> % if include_proctoring: + <%static:js group='proctoring'/> % for template_name in ["proctored-exam-status"]: