Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-proctoring
Commits
5f86df09
Commit
5f86df09
authored
Oct 06, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to turn off prerequisite enforcement
parent
e724f625
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
63 deletions
+72
-63
edx_proctoring/api.py
+17
-20
edx_proctoring/constants.py
+6
-0
edx_proctoring/tests/test_api.py
+49
-43
No files found.
edx_proctoring/api.py
View file @
5f86df09
...
@@ -1108,31 +1108,28 @@ def get_student_view(user_id, course_id, content_id,
...
@@ -1108,31 +1108,28 @@ def get_student_view(user_id, course_id, content_id,
credit_state
=
context
[
'credit_state'
]
credit_state
=
context
[
'credit_state'
]
has_mode
=
_check_eligibility_of_enrollment_mode
(
credit_state
)
has_mode
=
_check_eligibility_of_enrollment_mode
(
credit_state
)
has_prerequisites
=
False
if
not
has_mode
:
if
has_mode
:
return
None
has_prerequisites
=
_check_eligibility_of_prerequisites
(
credit_state
)
has_prerequisites
=
_check_eligibility_of_prerequisites
(
credit_state
)
# see if the user has passed all pre-requisite credit eligibility
# see if the user has passed all pre-requisite credit eligibility
# checks, otherwise just show the user the exam unproctored
# checks, otherwise just show the user the exam unproctored
if
not
has_
mode
or
not
has_prerequisites
:
if
not
has_
prerequisites
and
constants
.
ENFORCE_PREREQUISITES
:
# if we are in the right mode and if we don't have
# if we are in the right mode and if we don't have
# pre-requisites, then we implicitly decline the exam
# pre-requisites, then we implicitly decline the exam
if
has_mode
:
attempt
=
get_exam_attempt
(
exam_id
,
user_id
)
attempt
=
get_exam_attempt
(
exam_id
,
user_id
)
if
not
attempt
:
if
not
attempt
:
# user hasn't a record of attempt, create one now
# user hasn't a record of attempt, create one now
# so we can mark it as declined
# so we can mark it as declined
create_exam_attempt
(
exam_id
,
user_id
)
create_exam_attempt
(
exam_id
,
user_id
)
update_attempt_status
(
update_attempt_status
(
exam_id
,
exam_id
,
user_id
,
user_id
,
ProctoredExamStudentAttemptStatus
.
declined
,
ProctoredExamStudentAttemptStatus
.
declined
,
raise_if_not_found
=
False
raise_if_not_found
=
False
)
)
# don't override context, let the courseware show
return
None
attempt
=
get_exam_attempt
(
exam_id
,
user_id
)
attempt
=
get_exam_attempt
(
exam_id
,
user_id
)
...
...
edx_proctoring/constants.py
View file @
5f86df09
...
@@ -41,3 +41,9 @@ REQUIRE_FAILURE_SECOND_REVIEWS = (
...
@@ -41,3 +41,9 @@ REQUIRE_FAILURE_SECOND_REVIEWS = (
'REQUIRE_FAILURE_SECOND_REVIEWS'
in
settings
.
PROCTORING_SETTINGS
'REQUIRE_FAILURE_SECOND_REVIEWS'
in
settings
.
PROCTORING_SETTINGS
else
getattr
(
settings
,
'REQUIRE_FAILURE_SECOND_REVIEWS'
,
True
)
else
getattr
(
settings
,
'REQUIRE_FAILURE_SECOND_REVIEWS'
,
True
)
)
)
ENFORCE_PREREQUISITES
=
(
settings
.
PROCTORING_SETTINGS
[
'ENFORCE_PREREQUISITES'
]
if
'ENFORCE_PREREQUISITES'
in
settings
.
PROCTORING_SETTINGS
else
False
)
edx_proctoring/tests/test_api.py
View file @
5f86df09
...
@@ -724,14 +724,19 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -724,14 +724,19 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
assertIsNone
(
rendered_response
)
self
.
assertIsNone
(
rendered_response
)
@ddt.data
(
@ddt.data
(
(
'reverification'
,
None
,
True
,
True
,
False
),
(
True
,
'reverification'
,
None
,
True
,
True
,
False
),
(
'reverification'
,
'failed'
,
False
,
False
,
True
),
(
True
,
'reverification'
,
'failed'
,
False
,
False
,
True
),
(
'reverification'
,
'failed'
,
False
,
True
,
False
),
(
True
,
'reverification'
,
'failed'
,
True
,
True
,
False
),
(
'reverification'
,
'satisfied'
,
True
,
True
,
False
),
(
True
,
'reverification'
,
'satisfied'
,
True
,
True
,
False
),
(
'grade'
,
'failed'
,
True
,
False
,
False
)
(
True
,
'grade'
,
'failed'
,
True
,
False
,
False
),
(
False
,
'reverification'
,
None
,
True
,
True
,
False
),
(
False
,
'reverification'
,
'failed'
,
True
,
False
,
False
),
(
False
,
'reverification'
,
'failed'
,
True
,
True
,
False
),
(
False
,
'reverification'
,
'satisfied'
,
True
,
True
,
False
),
(
False
,
'grade'
,
'failed'
,
True
,
False
,
False
),
)
)
@ddt.unpack
@ddt.unpack
def
test_prereq_scenarios
(
self
,
namespace
,
req_status
,
show_proctored
,
def
test_prereq_scenarios
(
self
,
enforce_prereq
,
namespace
,
req_status
,
show_proctored
,
pre_create_attempt
,
mark_as_declined
):
pre_create_attempt
,
mark_as_declined
):
"""
"""
This test asserts that proctoring will not be displayed under the following
This test asserts that proctoring will not be displayed under the following
...
@@ -740,46 +745,47 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -740,46 +745,47 @@ class ProctoredExamApiTests(LoggedInTestCase):
- Verified student has not completed all 'reverification' requirements
- Verified student has not completed all 'reverification' requirements
"""
"""
exam
=
get_exam_by_id
(
self
.
proctored_exam_id
)
with
patch
(
'edx_proctoring.constants.ENFORCE_PREREQUISITES'
,
enforce_prereq
):
exam
=
get_exam_by_id
(
self
.
proctored_exam_id
)
if
pre_create_attempt
:
if
pre_create_attempt
:
create_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
create_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
# user hasn't attempted reverifications
# user hasn't attempted reverifications
rendered_response
=
get_student_view
(
rendered_response
=
get_student_view
(
user_id
=
self
.
user_id
,
user_id
=
self
.
user_id
,
course_id
=
exam
[
'course_id'
],
course_id
=
exam
[
'course_id'
],
content_id
=
exam
[
'content_id'
],
content_id
=
exam
[
'content_id'
],
context
=
{
context
=
{
'is_proctored'
:
True
,
'is_proctored'
:
True
,
'display_name'
:
self
.
exam_name
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
,
'default_time_limit_mins'
:
90
,
'is_practice_exam'
:
False
,
'is_practice_exam'
:
False
,
'credit_state'
:
{
'credit_state'
:
{
'enrollment_mode'
:
'verified'
,
'enrollment_mode'
:
'verified'
,
'credit_requirement_status'
:
[
'credit_requirement_status'
:
[
{
{
'namespace'
:
namespace
,
'namespace'
:
namespace
,
'status'
:
req_status
,
'status'
:
req_status
,
}
}
]
]
}
}
}
}
)
)
if
show_proctored
:
if
show_proctored
:
self
.
assertIsNotNone
(
rendered_response
)
self
.
assertIsNotNone
(
rendered_response
)
else
:
else
:
self
.
assertIsNone
(
rendered_response
)
self
.
assertIsNone
(
rendered_response
)
# also the user should have been marked as declined in certain
# also the user should have been marked as declined in certain
# cases
# cases
if
mark_as_declined
:
if
mark_as_declined
:
attempt
=
get_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
attempt
=
get_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
self
.
assertEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
declined
)
self
.
assertEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
declined
)
else
:
else
:
attempt
=
get_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
attempt
=
get_exam_attempt
(
self
.
proctored_exam_id
,
self
.
user_id
)
if
attempt
:
if
attempt
:
self
.
assertNotEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
declined
)
self
.
assertNotEqual
(
attempt
[
'status'
],
ProctoredExamStudentAttemptStatus
.
declined
)
def
test_student_view_non_student
(
self
):
def
test_student_view_non_student
(
self
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment