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
1006eb1d
Commit
1006eb1d
authored
Mar 04, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #279 from edx/mushtaq/TNL-4175-fix-timed-exam-timer
Fetch correct remaining seconds from proctoring
parents
5e1cd817
5cebdb19
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
2 deletions
+44
-2
AUTHORS
+1
-0
edx_proctoring/static/proctoring/js/models/proctored_exam_model.js
+1
-1
edx_proctoring/tests/test_views.py
+41
-0
edx_proctoring/utils.py
+1
-1
No files found.
AUTHORS
View file @
1006eb1d
Chris Dodge <cdodge@edx.org>
Chris Dodge <cdodge@edx.org>
Muhammad Shoaib <mshoaib@edx.org>
Muhammad Shoaib <mshoaib@edx.org>
Afzal Wali <afzal@edx.org>
Afzal Wali <afzal@edx.org>
Mushtaq Ali <mushtaak@gmail.com>
edx_proctoring/static/proctoring/js/models/proctored_exam_model.js
View file @
1006eb1d
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
if
(
secondsLeft
<
0
)
if
(
secondsLeft
<
0
)
secondsLeft
=
0
;
secondsLeft
=
0
;
var
hours
=
parseInt
(
secondsLeft
/
3600
)
%
24
;
var
hours
=
parseInt
(
secondsLeft
/
3600
);
var
minutes
=
parseInt
(
secondsLeft
/
60
)
%
60
;
var
minutes
=
parseInt
(
secondsLeft
/
60
)
%
60
;
var
seconds
=
Math
.
floor
(
secondsLeft
%
60
);
var
seconds
=
Math
.
floor
(
secondsLeft
%
60
);
...
...
edx_proctoring/tests/test_views.py
View file @
1006eb1d
...
@@ -638,6 +638,47 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
...
@@ -638,6 +638,47 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self
.
assertEqual
(
response_data
[
'accessibility_time_string'
],
'you have less than a minute remaining'
)
self
.
assertEqual
(
response_data
[
'accessibility_time_string'
],
'you have less than a minute remaining'
)
def
test_timer_remaining_time
(
self
):
"""
Test that remaining time is calculated correctly
"""
# Create an exam with 30 hours ( 30 * 60) total time
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
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'external_id'
:
proctored_exam
.
external_id
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
attempt_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
json
.
loads
(
response
.
content
)
attempt_id
=
response_data
[
'exam_attempt_id'
]
self
.
assertGreater
(
attempt_id
,
0
)
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
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
# check that we get timer arround 30 hours minus some seconds
self
.
assertTrue
(
107990
<=
response_data
[
'time_remaining_seconds'
]
<=
108000
)
# check that humanized time
self
.
assertEqual
(
response_data
[
'accessibility_time_string'
],
'you have 30 hours remaining'
)
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 @
1006eb1d
...
@@ -47,7 +47,7 @@ def get_time_remaining_for_attempt(attempt):
...
@@ -47,7 +47,7 @@ def get_time_remaining_for_attempt(attempt):
now_utc
=
datetime
.
now
(
pytz
.
UTC
)
now_utc
=
datetime
.
now
(
pytz
.
UTC
)
if
expires_at
>
now_utc
:
if
expires_at
>
now_utc
:
time_remaining_seconds
=
(
expires_at
-
now_utc
)
.
seconds
time_remaining_seconds
=
(
expires_at
-
now_utc
)
.
total_seconds
()
else
:
else
:
time_remaining_seconds
=
0
time_remaining_seconds
=
0
...
...
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