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
2408ca17
Commit
2408ca17
authored
Oct 20, 2015
by
Hasnain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timed exam allowed minutes on entrance template
parent
68eb2140
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
12 deletions
+30
-12
edx_proctoring/api.py
+30
-12
No files found.
edx_proctoring/api.py
View file @
2408ca17
...
...
@@ -394,24 +394,16 @@ def create_exam_attempt(exam_id, user_id, taking_as_proctored=False):
raise
StudentExamAttemptAlreadyExistsException
(
err_msg
)
allowed_time_limit_mins
=
exam
[
'time_limit_mins'
]
due_datetime
=
exam
[
'due_date'
]
current_datetime
=
datetime
.
now
(
pytz
.
UTC
)
is_exam_past_due_date
=
False
# add in the allowed additional time
allowance_extra_mins
=
ProctoredExamStudentAllowance
.
get_additional_time_granted
(
exam_id
,
user_id
)
if
allowance_extra_mins
:
allowed_time_limit_mins
+=
allowance_extra_mins
if
due_datetime
:
if
_has_due_date_passed
(
due_datetime
):
is_exam_past_due_date
=
True
elif
current_datetime
+
timedelta
(
minutes
=
allowed_time_limit_mins
)
>
due_datetime
:
# e.g current_datetime=09:00, due_datetime=10:00 and allowed_time_limit_mins=120(2hours)
# then allowed_time_limit_mins should be 60(1hour)
allowed_time_limit_mins
=
int
((
due_datetime
-
current_datetime
)
.
seconds
/
60
)
allowed_time_limit_mins
,
is_exam_past_due_date
=
_calculate_allowed_mins
(
exam
[
'due_date'
],
allowed_time_limit_mins
)
attempt_code
=
unicode
(
uuid
.
uuid4
())
.
upper
()
...
...
@@ -1309,6 +1301,11 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
if
allowance
:
allowed_time_limit_mins
+=
int
(
allowance
.
value
)
allowed_time_limit_mins
,
_
=
_calculate_allowed_mins
(
exam
[
'due_date'
],
allowed_time_limit_mins
)
total_time
=
humanized_time
(
allowed_time_limit_mins
)
progress_page_url
=
''
try
:
...
...
@@ -1336,6 +1333,27 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
return
template
.
render
(
django_context
)
def
_calculate_allowed_mins
(
due_datetime
,
allowed_mins
):
"""
Returns the allowed minutes w.r.t due date and has due date pass
"""
current_datetime
=
datetime
.
now
(
pytz
.
UTC
)
is_exam_past_due_date
=
False
actual_allowed_mins
=
allowed_mins
if
due_datetime
:
if
_has_due_date_passed
(
due_datetime
):
is_exam_past_due_date
=
True
elif
current_datetime
+
timedelta
(
minutes
=
allowed_mins
)
>
due_datetime
:
# e.g current_datetime=09:00, due_datetime=10:00 and allowed_mins=120(2hours)
# then allowed_mins should be 60(1hour)
actual_allowed_mins
=
int
((
due_datetime
-
current_datetime
)
.
seconds
/
60
)
return
actual_allowed_mins
,
is_exam_past_due_date
def
_get_proctored_exam_context
(
exam
,
attempt
,
course_id
,
is_practice_exam
=
False
):
"""
Common context variables for the Proctored and Practice exams' templates.
...
...
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