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
a7a00907
Commit
a7a00907
authored
Mar 10, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timer time difference issue. TNL-4216
parent
eaf8a896
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
edx_proctoring/api.py
+1
-1
edx_proctoring/tests/test_views.py
+24
-1
edx_proctoring/utils.py
+1
-1
No files found.
edx_proctoring/api.py
View file @
a7a00907
...
@@ -1522,7 +1522,7 @@ def _calculate_allowed_mins(due_datetime, allowed_mins):
...
@@ -1522,7 +1522,7 @@ def _calculate_allowed_mins(due_datetime, allowed_mins):
# e.g current_datetime=09:00, due_datetime=10:00 and allowed_mins=120(2hours)
# e.g current_datetime=09:00, due_datetime=10:00 and allowed_mins=120(2hours)
# then allowed_mins should be 60(1hour)
# then allowed_mins should be 60(1hour)
actual_allowed_mins
=
int
((
due_datetime
-
current_datetime
)
.
seconds
/
60
)
actual_allowed_mins
=
int
((
due_datetime
-
current_datetime
)
.
total_seconds
()
/
60
)
return
actual_allowed_mins
,
is_exam_past_due_date
return
actual_allowed_mins
,
is_exam_past_due_date
...
...
edx_proctoring/tests/test_views.py
View file @
a7a00907
...
@@ -29,6 +29,7 @@ from edx_proctoring.api import (
...
@@ -29,6 +29,7 @@ from edx_proctoring.api import (
create_exam_attempt
,
create_exam_attempt
,
get_exam_attempt_by_id
,
get_exam_attempt_by_id
,
update_attempt_status
,
update_attempt_status
,
_calculate_allowed_mins
)
)
from
.utils
import
(
from
.utils
import
(
...
@@ -674,11 +675,33 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
...
@@ -674,11 +675,33 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self
.
assertEqual
(
response_data
[
'proctored_exam'
][
'id'
],
proctored_exam
.
id
)
self
.
assertEqual
(
response_data
[
'proctored_exam'
][
'id'
],
proctored_exam
.
id
)
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
# check that we get timer ar
r
ound 30 hours minus some seconds
# check that we get timer around 30 hours minus some seconds
self
.
assertTrue
(
107990
<=
response_data
[
'time_remaining_seconds'
]
<=
108000
)
self
.
assertTrue
(
107990
<=
response_data
[
'time_remaining_seconds'
]
<=
108000
)
# check that humanized time
# check that humanized time
self
.
assertEqual
(
response_data
[
'accessibility_time_string'
],
'you have 30 hours remaining'
)
self
.
assertEqual
(
response_data
[
'accessibility_time_string'
],
'you have 30 hours remaining'
)
def
test_time_due_date_between_two_days
(
self
):
"""
Test that we get correct total time left to attempt if due date is 24+ hours from now and we have set 24+ hours
time_limit_mins ( 27 hours ) i.e it is like 1 day and 3 hours total time left to attempt the exam.
"""
# Create an exam with 30 hours ( 1800 minutes ) total time with expected 27 hours time left to attempt.
expected_total_minutes
=
27
*
60
proctored_exam
=
ProctoredExam
.
objects
.
create
(
course_id
=
'a/b/c'
,
content_id
=
'test_content'
,
exam_name
=
'Test Exam'
,
external_id
=
'123aXqe3'
,
time_limit_mins
=
1800
,
due_date
=
datetime
.
now
(
pytz
.
UTC
)
+
timedelta
(
minutes
=
expected_total_minutes
),
)
total_minutes
,
__
=
_calculate_allowed_mins
(
proctored_exam
.
due_date
,
proctored_exam
.
time_limit_mins
)
# Check that timer has > 24 hours
self
.
assertTrue
(
total_minutes
/
60
>
24
)
# Get total_minutes around 27 hours. We are checking range here because while testing some seconds have passed.
self
.
assertTrue
(
expected_total_minutes
-
1
<=
total_minutes
<=
expected_total_minutes
)
def
test_attempt_ready_to_start
(
self
):
def
test_attempt_ready_to_start
(
self
):
"""
"""
Test to get an attempt with ready_to_start status
Test to get an attempt with ready_to_start status
...
...
edx_proctoring/utils.py
View file @
a7a00907
...
@@ -170,7 +170,7 @@ def emit_event(exam, event_short_name, attempt=None, override_data=None):
...
@@ -170,7 +170,7 @@ def emit_event(exam, event_short_name, attempt=None, override_data=None):
# This can be used to determine how far into an attempt a given
# This can be used to determine how far into an attempt a given
# event occured (e.g. "time to complete exam")
# event occured (e.g. "time to complete exam")
attempt_event_elapsed_time_secs
=
(
attempt_event_elapsed_time_secs
=
(
(
datetime
.
now
(
pytz
.
UTC
)
-
attempt
[
'started_at'
])
.
seconds
if
attempt
[
'started_at'
]
else
(
datetime
.
now
(
pytz
.
UTC
)
-
attempt
[
'started_at'
])
.
total_seconds
()
if
attempt
[
'started_at'
]
else
None
None
)
)
...
...
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