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
OpenEdx
edx-proctoring
Commits
0393d4ec
Commit
0393d4ec
authored
Nov 18, 2015
by
ibrahimahmed443
Committed by
Chris Dodge
Nov 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strip out unicode characters when registering exams with Software Secure
change parameter name
parent
6f649553
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
edx_proctoring/backends/software_secure.py
+2
-0
edx_proctoring/backends/tests/test_software_secure.py
+46
-0
No files found.
edx_proctoring/backends/software_secure.py
View file @
0393d4ec
...
@@ -11,6 +11,7 @@ import binascii
...
@@ -11,6 +11,7 @@ import binascii
import
datetime
import
datetime
import
json
import
json
import
logging
import
logging
import
unicodedata
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -377,6 +378,7 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
...
@@ -377,6 +378,7 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
end_time_str
=
(
now
+
datetime
.
timedelta
(
minutes
=
time_limit_mins
))
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
end_time_str
=
(
now
+
datetime
.
timedelta
(
minutes
=
time_limit_mins
))
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
# remove all illegal characters from the exam name
# remove all illegal characters from the exam name
exam_name
=
exam
[
'exam_name'
]
exam_name
=
exam
[
'exam_name'
]
exam_name
=
unicodedata
.
normalize
(
'NFKD'
,
exam_name
)
.
encode
(
'ascii'
,
'ignore'
)
for
character
in
SOFTWARE_SECURE_INVALID_CHARS
:
for
character
in
SOFTWARE_SECURE_INVALID_CHARS
:
exam_name
=
exam_name
.
replace
(
character
,
'_'
)
exam_name
=
exam_name
.
replace
(
character
,
'_'
)
return
{
return
{
...
...
edx_proctoring/backends/tests/test_software_secure.py
View file @
0393d4ec
...
@@ -266,6 +266,52 @@ class SoftwareSecureTests(TestCase):
...
@@ -266,6 +266,52 @@ class SoftwareSecureTests(TestCase):
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertIsNone
(
attempt
[
'review_policy_id'
])
self
.
assertIsNone
(
attempt
[
'review_policy_id'
])
def
test_attempt_with_unicode_characters
(
self
):
"""
test that the unicode characters are removed from exam names before registering with
software secure.
"""
def
is_ascii
(
value
):
"""
returns True if string is ascii and False otherwise.
"""
try
:
value
.
encode
(
'ascii'
)
return
True
except
UnicodeEncodeError
:
return
False
def
assert_get_payload_mock_unicode_characters
(
exam
,
context
):
"""
Add a mock so we can assert that the _get_payload call removes unicode characters.
"""
# call into real implementation
result
=
get_backend_provider
(
emphemeral
=
True
)
.
_get_payload
(
exam
,
context
)
# pylint: disable=protected-access
self
.
assertFalse
(
isinstance
(
result
[
'examName'
],
unicode
))
self
.
assertTrue
(
is_ascii
(
result
[
'examName'
]))
return
result
exam_id
=
create_exam
(
course_id
=
'foo/bar/baz'
,
content_id
=
'content with unicode characters'
,
exam_name
=
u'Klüft skräms inför på fédéral électoral große'
,
time_limit_mins
=
10
,
is_proctored
=
True
)
with
HTTMock
(
mock_response_content
):
# patch the _get_payload method on the backend provider
with
patch
.
object
(
get_backend_provider
(),
'_get_payload'
,
assert_get_payload_mock_unicode_characters
):
# pylint: disable=protected-access
attempt_id
=
create_exam_attempt
(
exam_id
,
self
.
user
.
id
,
taking_as_proctored
=
True
)
self
.
assertGreater
(
attempt_id
,
0
)
def
test_single_name_attempt
(
self
):
def
test_single_name_attempt
(
self
):
"""
"""
Tests to make sure we can parse a fullname which does not have any spaces in it
Tests to make sure we can parse a fullname which does not have any spaces in it
...
...
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