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
b4d10695
Commit
b4d10695
authored
May 09, 2017
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix quality failures with new edx-lint version
parent
fa622bcb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
35 deletions
+32
-35
edx_proctoring/admin.py
+10
-15
edx_proctoring/api.py
+4
-3
edx_proctoring/backends/tests/test_backend.py
+2
-0
edx_proctoring/models.py
+2
-2
edx_proctoring/tests/test_models.py
+2
-0
edx_proctoring/views.py
+12
-15
No files found.
edx_proctoring/admin.py
View file @
b4d10695
...
@@ -107,8 +107,7 @@ class ReviewListFilter(admin.SimpleListFilter):
...
@@ -107,8 +107,7 @@ class ReviewListFilter(admin.SimpleListFilter):
return
queryset
.
filter
(
reviewed_by__isnull
=
True
)
return
queryset
.
filter
(
reviewed_by__isnull
=
True
)
elif
self
.
value
()
==
'all_unreviewed_failures'
:
elif
self
.
value
()
==
'all_unreviewed_failures'
:
return
queryset
.
filter
(
reviewed_by__isnull
=
True
,
review_status
=
'Suspicious'
)
return
queryset
.
filter
(
reviewed_by__isnull
=
True
,
review_status
=
'Suspicious'
)
else
:
return
queryset
return
queryset
class
ProctoredExamListFilter
(
admin
.
SimpleListFilter
):
class
ProctoredExamListFilter
(
admin
.
SimpleListFilter
):
...
@@ -252,25 +251,22 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
...
@@ -252,25 +251,22 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
"""Return course_id associated with review"""
"""Return course_id associated with review"""
if
obj
.
exam
:
if
obj
.
exam
:
return
obj
.
exam
.
course_id
return
obj
.
exam
.
course_id
else
:
exam
=
self
.
_get_exam_from_attempt_code
(
obj
.
attempt_code
)
exam
=
self
.
_get_exam_from_attempt_code
(
obj
.
attempt_code
)
return
exam
.
exam_name
if
exam
else
'(none)'
return
exam
.
exam_name
if
exam
else
'(none)'
def
exam_name_for_review
(
self
,
obj
):
def
exam_name_for_review
(
self
,
obj
):
"""Return course_id associated with review"""
"""Return course_id associated with review"""
if
obj
.
exam
:
if
obj
.
exam
:
return
obj
.
exam
.
exam_name
return
obj
.
exam
.
exam_name
else
:
exam
=
self
.
_get_exam_from_attempt_code
(
obj
.
attempt_code
)
exam
=
self
.
_get_exam_from_attempt_code
(
obj
.
attempt_code
)
return
exam
.
exam_name
if
exam
else
'(none)'
return
exam
.
exam_name
if
exam
else
'(none)'
def
student_username_for_review
(
self
,
obj
):
def
student_username_for_review
(
self
,
obj
):
"""Return username of student who took the test"""
"""Return username of student who took the test"""
if
obj
.
student
:
if
obj
.
student
:
return
obj
.
student
.
username
return
obj
.
student
.
username
else
:
(
attempt_obj
,
__
)
=
locate_attempt_by_attempt_code
(
obj
.
attempt_code
)
(
attempt_obj
,
__
)
=
locate_attempt_by_attempt_code
(
obj
.
attempt_code
)
return
attempt_obj
.
user
.
username
if
attempt_obj
else
'(None)'
return
attempt_obj
.
user
.
username
if
attempt_obj
else
'(None)'
list_display
=
[
list_display
=
[
'course_id_for_review'
,
'course_id_for_review'
,
...
@@ -290,7 +286,7 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
...
@@ -290,7 +286,7 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
""" Allow deletes """
""" Allow deletes """
return
True
return
True
def
save_model
(
self
,
request
,
review
,
form
,
change
):
def
save_model
(
self
,
request
,
review
,
form
,
change
):
# pylint: disable=arguments-differ
"""
"""
Override callback so that we can inject the user_id that made the change
Override callback so that we can inject the user_id that made the change
"""
"""
...
@@ -306,7 +302,7 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
...
@@ -306,7 +302,7 @@ class ProctoredExamSoftwareSecureReviewAdmin(admin.ModelAdmin):
del
form
.
base_fields
[
'video_url'
]
del
form
.
base_fields
[
'video_url'
]
return
form
return
form
def
lookup_allowed
(
self
,
key
,
value
):
def
lookup_allowed
(
self
,
key
,
value
):
# pylint: disable=arguments-differ
if
key
==
'exam__course_id'
:
if
key
==
'exam__course_id'
:
return
True
return
True
return
super
(
ProctoredExamSoftwareSecureReviewAdmin
,
self
)
.
lookup_allowed
(
key
,
value
)
return
super
(
ProctoredExamSoftwareSecureReviewAdmin
,
self
)
.
lookup_allowed
(
key
,
value
)
...
@@ -363,8 +359,7 @@ class ExamAttemptFilterByCourseId(admin.SimpleListFilter):
...
@@ -363,8 +359,7 @@ class ExamAttemptFilterByCourseId(admin.SimpleListFilter):
"""
"""
if
self
.
value
():
if
self
.
value
():
return
queryset
.
filter
(
proctored_exam__course_id
=
self
.
value
())
return
queryset
.
filter
(
proctored_exam__course_id
=
self
.
value
())
else
:
return
queryset
return
queryset
class
ProctoredExamAttemptForm
(
forms
.
ModelForm
):
class
ProctoredExamAttemptForm
(
forms
.
ModelForm
):
...
...
edx_proctoring/api.py
View file @
b4d10695
...
@@ -56,6 +56,8 @@ log = logging.getLogger(__name__)
...
@@ -56,6 +56,8 @@ log = logging.getLogger(__name__)
SHOW_EXPIRY_MESSAGE_DURATION
=
1
*
60
# duration within which expiry message is shown for a timed-out exam
SHOW_EXPIRY_MESSAGE_DURATION
=
1
*
60
# duration within which expiry message is shown for a timed-out exam
APPROVED_STATUS
=
'approved'
def
create_exam
(
course_id
,
content_id
,
exam_name
,
time_limit_mins
,
due_date
=
None
,
def
create_exam
(
course_id
,
content_id
,
exam_name
,
time_limit_mins
,
due_date
=
None
,
is_proctored
=
True
,
is_practice_exam
=
False
,
external_id
=
None
,
is_active
=
True
,
hide_after_due
=
False
):
is_proctored
=
True
,
is_practice_exam
=
False
,
external_id
=
None
,
is_active
=
True
,
hide_after_due
=
False
):
...
@@ -1762,7 +1764,7 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
...
@@ -1762,7 +1764,7 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
return
None
return
None
elif
attempt_status
in
[
ProctoredExamStudentAttemptStatus
.
created
,
elif
attempt_status
in
[
ProctoredExamStudentAttemptStatus
.
created
,
ProctoredExamStudentAttemptStatus
.
download_software_clicked
]:
ProctoredExamStudentAttemptStatus
.
download_software_clicked
]:
if
context
.
get
(
'verification_status'
)
is
not
'approved'
:
if
context
.
get
(
'verification_status'
)
is
not
APPROVED_STATUS
:
# if the user has not id verified yet, show them the page that requires them to do so
# if the user has not id verified yet, show them the page that requires them to do so
student_view_template
=
'proctored_exam/id_verification.html'
student_view_template
=
'proctored_exam/id_verification.html'
else
:
else
:
...
@@ -1879,5 +1881,4 @@ def get_student_view(user_id, course_id, content_id,
...
@@ -1879,5 +1881,4 @@ def get_student_view(user_id, course_id, content_id,
if
sub_view_func
:
if
sub_view_func
:
return
sub_view_func
(
exam
,
context
,
exam_id
,
user_id
,
course_id
)
return
sub_view_func
(
exam
,
context
,
exam_id
,
user_id
,
course_id
)
else
:
return
None
return
None
edx_proctoring/backends/tests/test_backend.py
View file @
b4d10695
...
@@ -13,6 +13,8 @@ from edx_proctoring.backends.backend import ProctoringBackendProvider
...
@@ -13,6 +13,8 @@ from edx_proctoring.backends.backend import ProctoringBackendProvider
from
edx_proctoring.backends.null
import
NullBackendProvider
from
edx_proctoring.backends.null
import
NullBackendProvider
from
edx_proctoring.backends.mock
import
MockProctoringBackendProvider
from
edx_proctoring.backends.mock
import
MockProctoringBackendProvider
# pragma pylint: disable=useless-super-delegation
class
TestBackendProvider
(
ProctoringBackendProvider
):
class
TestBackendProvider
(
ProctoringBackendProvider
):
"""
"""
...
...
edx_proctoring/models.py
View file @
b4d10695
...
@@ -304,7 +304,7 @@ class ProctoredExamReviewPolicyHistory(TimeStampedModel):
...
@@ -304,7 +304,7 @@ class ProctoredExamReviewPolicyHistory(TimeStampedModel):
db_table
=
'proctoring_proctoredexamreviewpolicyhistory'
db_table
=
'proctoring_proctoredexamreviewpolicyhistory'
verbose_name
=
'proctored exam review policy history'
verbose_name
=
'proctored exam review policy history'
def
delete
(
self
,
*
args
,
**
kwargs
):
def
delete
(
self
,
*
args
,
**
kwargs
):
# pylint: disable=arguments-differ
"""
"""
Don't allow deletions!
Don't allow deletions!
"""
"""
...
@@ -747,7 +747,7 @@ class ProctoredExamStudentAllowance(TimeStampedModel):
...
@@ -747,7 +747,7 @@ class ProctoredExamStudentAllowance(TimeStampedModel):
user_id
=
None
user_id
=
None
# see if key is a tuple, if it is, then the first element is the key
# see if key is a tuple, if it is, then the first element is the key
if
isinstance
(
key
,
tuple
)
and
len
(
key
)
>
0
:
if
isinstance
(
key
,
tuple
)
and
len
(
key
)
>
0
:
# pylint: disable=len-as-condition
key
=
key
[
0
]
key
=
key
[
0
]
if
not
cls
.
is_allowance_value_valid
(
key
,
value
):
if
not
cls
.
is_allowance_value_valid
(
key
,
value
):
...
...
edx_proctoring/tests/test_models.py
View file @
b4d10695
...
@@ -21,6 +21,8 @@ from .utils import (
...
@@ -21,6 +21,8 @@ from .utils import (
LoggedInTestCase
LoggedInTestCase
)
)
# pragma pylint: disable=useless-super-delegation
class
ProctoredExamModelTests
(
LoggedInTestCase
):
class
ProctoredExamModelTests
(
LoggedInTestCase
):
"""
"""
...
...
edx_proctoring/views.py
View file @
b4d10695
...
@@ -63,11 +63,10 @@ def require_staff(func):
...
@@ -63,11 +63,10 @@ def require_staff(func):
def
wrapped
(
request
,
*
args
,
**
kwargs
):
# pylint: disable=missing-docstring
def
wrapped
(
request
,
*
args
,
**
kwargs
):
# pylint: disable=missing-docstring
if
request
.
user
.
is_staff
:
if
request
.
user
.
is_staff
:
return
func
(
request
,
*
args
,
**
kwargs
)
return
func
(
request
,
*
args
,
**
kwargs
)
else
:
return
Response
(
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
,
status
=
status
.
HTTP_403_FORBIDDEN
,
data
=
{
"detail"
:
"Must be a Staff User to Perform this request."
}
data
=
{
"detail"
:
"Must be a Staff User to Perform this request."
}
)
)
return
wrapped
return
wrapped
...
@@ -96,11 +95,10 @@ def require_course_or_global_staff(func):
...
@@ -96,11 +95,10 @@ def require_course_or_global_staff(func):
)
)
if
instructor_service
.
is_course_staff
(
request
.
user
,
course_id
):
if
instructor_service
.
is_course_staff
(
request
.
user
,
course_id
):
return
func
(
request
,
*
args
,
**
kwargs
)
return
func
(
request
,
*
args
,
**
kwargs
)
else
:
return
Response
(
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
,
status
=
status
.
HTTP_403_FORBIDDEN
,
data
=
{
"detail"
:
_
(
"Must be a Staff User to Perform this request."
)}
data
=
{
"detail"
:
_
(
"Must be a Staff User to Perform this request."
)}
)
)
return
wrapped
return
wrapped
...
@@ -191,11 +189,10 @@ class ProctoredExamView(AuthenticatedAPIView):
...
@@ -191,11 +189,10 @@ class ProctoredExamView(AuthenticatedAPIView):
hide_after_due
=
request
.
data
.
get
(
'hide_after_due'
,
None
),
hide_after_due
=
request
.
data
.
get
(
'hide_after_due'
,
None
),
)
)
return
Response
({
'exam_id'
:
exam_id
})
return
Response
({
'exam_id'
:
exam_id
})
else
:
return
Response
(
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
,
status
=
status
.
HTTP_400_BAD_REQUEST
,
data
=
serializer
.
errors
data
=
serializer
.
errors
)
)
@method_decorator
(
require_staff
)
@method_decorator
(
require_staff
)
def
put
(
self
,
request
):
def
put
(
self
,
request
):
...
...
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