Skip to content
Snippets Groups Projects
Unverified Commit acbefd10 authored by Igor Degtiarov's avatar Igor Degtiarov Committed by GitHub
Browse files

Extend appropriate proctoring exam modes if provider allows it. (#25927)

The honor enrollment mode is widely used in OpenEdx installations,
and recently it was not allowed for proctoring exam, but very anticipated.

Current PR makes it possible to start the proctoring exam in the honor enrollment
mode in case the provider is configured in that way.
parent 3cd212ee
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,12 @@ def is_track_ok_for_exam(user, exam): ...@@ -37,7 +37,12 @@ def is_track_ok_for_exam(user, exam):
""" """
course_id = CourseKey.from_string(exam['course_id']) course_id = CourseKey.from_string(exam['course_id'])
mode, is_active = CourseEnrollment.enrollment_mode_for_user(user, course_id) mode, is_active = CourseEnrollment.enrollment_mode_for_user(user, course_id)
return is_active and mode in (CourseMode.VERIFIED, CourseMode.MASTERS, CourseMode.PROFESSIONAL, CourseMode.EXECUTIVE_EDUCATION) appropriate_modes = [
CourseMode.VERIFIED, CourseMode.MASTERS, CourseMode.PROFESSIONAL, CourseMode.EXECUTIVE_EDUCATION
]
if exam.get('is_proctored') and settings.PROCTORING_BACKENDS.get(exam['backend'], {}).get('allow_honor_mode'):
appropriate_modes.append(CourseMode.HONOR)
return is_active and mode in appropriate_modes
# The edx_proctoring.api uses this permission to gate access to the # The edx_proctoring.api uses this permission to gate access to the
......
...@@ -6,6 +6,7 @@ Tests for permissions defined in courseware.rules ...@@ -6,6 +6,7 @@ Tests for permissions defined in courseware.rules
import ddt import ddt
import six import six
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from common.djangoapps.course_modes.tests.factories import CourseModeFactory from common.djangoapps.course_modes.tests.factories import CourseModeFactory
...@@ -50,3 +51,26 @@ class PermissionTests(TestCase): ...@@ -50,3 +51,26 @@ class PermissionTests(TestCase):
has_perm = self.user.has_perm('edx_proctoring.can_take_proctored_exam', has_perm = self.user.has_perm('edx_proctoring.can_take_proctored_exam',
{'course_id': six.text_type(self.course_id)}) {'course_id': six.text_type(self.course_id)})
assert has_perm == should_have_perm assert has_perm == should_have_perm
@override_settings(
PROCTORING_BACKENDS={
'mock_proctoring_allow_honor_mode': {
'allow_honor_mode': True,
},
}
)
def test_proctoring_perm_with_honor_mode_permission(self):
"""
Test that the user has the edx_proctoring.can_take_proctored_exam permission in honor enrollment mode.
If proctoring backend configuration allows exam in honor mode {`allow_honor_mode`: True} the user is
granter proctored exam permission.
"""
CourseEnrollment.enroll(self.user, self.course_id, mode='honor')
self.assertTrue(self.user.has_perm(
'edx_proctoring.can_take_proctored_exam', {
'course_id': six.text_type(self.course_id),
'backend': 'mock_proctoring_allow_honor_mode',
'is_proctored': True
}
))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment