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
53968f79
Commit
53968f79
authored
Aug 27, 2015
by
Muhammad Shoaib
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #124 from edx/muhhshoaib/bug-when-calculating-remaining-time
Fixed the Bug
parents
29db1311
f6750c1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
edx_proctoring/tests/test_views.py
+31
-0
edx_proctoring/utils.py
+4
-0
No files found.
edx_proctoring/tests/test_views.py
View file @
53968f79
...
@@ -502,6 +502,37 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
...
@@ -502,6 +502,37 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
def
test_attempt_ready_to_start
(
self
):
"""
Test to get an attempt with ready_to_start status
and will return the response_data with time time_remaining_seconds to 0
"""
# Create an exam.
proctored_exam
=
ProctoredExam
.
objects
.
create
(
course_id
=
'a/b/c'
,
content_id
=
'test_content'
,
exam_name
=
'Test Exam'
,
external_id
=
'123aXqe3'
,
time_limit_mins
=
90
)
attempt
=
ProctoredExamStudentAttempt
.
create_exam_attempt
(
proctored_exam
.
id
,
self
.
user
.
id
,
'test_user'
,
1
,
'test_attempt_code'
,
True
,
False
,
'test_external_id'
)
attempt
.
status
=
ProctoredExamStudentAttemptStatus
.
ready_to_start
attempt
.
save
()
response
=
self
.
client
.
get
(
reverse
(
'edx_proctoring.proctored_exam.attempt'
,
args
=
[
attempt
.
id
])
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
response_data
[
'id'
],
attempt
.
id
)
self
.
assertEqual
(
response_data
[
'proctored_exam'
][
'id'
],
proctored_exam
.
id
)
self
.
assertIsNone
(
response_data
[
'started_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
self
.
assertEqual
(
response_data
[
'time_remaining_seconds'
],
0
)
def
test_attempt_status_error
(
self
):
def
test_attempt_status_error
(
self
):
"""
"""
Test to confirm that attempt status is marked as error, because client
Test to confirm that attempt status is marked as error, because client
...
...
edx_proctoring/utils.py
View file @
53968f79
...
@@ -24,6 +24,10 @@ def get_time_remaining_for_attempt(attempt):
...
@@ -24,6 +24,10 @@ def get_time_remaining_for_attempt(attempt):
Returns the remaining time (in seconds) on an attempt
Returns the remaining time (in seconds) on an attempt
"""
"""
# returns 0 if the attempt has not been started yet.
if
attempt
[
'started_at'
]
is
None
:
return
0
# need to adjust for allowances
# need to adjust for allowances
expires_at
=
attempt
[
'started_at'
]
+
timedelta
(
minutes
=
attempt
[
'allowed_time_limit_mins'
])
expires_at
=
attempt
[
'started_at'
]
+
timedelta
(
minutes
=
attempt
[
'allowed_time_limit_mins'
])
now_utc
=
datetime
.
now
(
pytz
.
UTC
)
now_utc
=
datetime
.
now
(
pytz
.
UTC
)
...
...
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