Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
ef2f20a6
Commit
ef2f20a6
authored
Feb 04, 2014
by
Jason Bau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HACKED TOGETHER time limit for DB class midterm
parent
18d6d411
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
common/lib/xmodule/xmodule/capa_module.py
+39
-2
lms/templates/problem.html
+19
-1
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
ef2f20a6
...
...
@@ -141,7 +141,9 @@ class CapaFields(object):
student_answers
=
Dict
(
help
=
"Dictionary with the current student responses"
,
scope
=
Scope
.
user_state
)
done
=
Boolean
(
help
=
"Whether the student has answered the problem"
,
scope
=
Scope
.
user_state
)
seed
=
Integer
(
help
=
"Random seed for this student"
,
scope
=
Scope
.
user_state
)
minutes_allowed
=
Integer
(
help
=
"EXPERIMENTAL FEATURE: DO NOT USE. Number of minutes allowed to finish this assessment. Set 0 for no time-limit"
,
default
=
0
,
scope
=
Scope
.
settings
)
time_started
=
Date
(
help
=
"time student started this assessment"
,
scope
=
Scope
.
user_state
)
last_submission_time
=
Date
(
help
=
"Last submission time"
,
scope
=
Scope
.
user_state
)
submission_wait_seconds
=
Integer
(
display_name
=
"Timer Between Attempts"
,
...
...
@@ -311,6 +313,12 @@ class CapaModule(CapaFields, XModule):
self
.
student_answers
=
lcp_state
[
'student_answers'
]
self
.
seed
=
lcp_state
[
'seed'
]
def
set_time_started
(
self
):
"""
Sets the time when the student started the module.
"""
self
.
time_started
=
datetime
.
datetime
.
now
(
UTC
())
def
set_last_submission_time
(
self
):
"""
Set the module's last submission time (when the problem was checked)
...
...
@@ -551,6 +559,20 @@ class CapaModule(CapaFields, XModule):
else
:
check_button
=
False
problem_is_timed
=
self
.
minutes_allowed
>
0
if
problem_is_timed
and
not
self
.
time_started
:
self
.
set_time_started
()
end_time_to_display
=
(
self
.
time_started
+
datetime
.
timedelta
(
minutes
=
self
.
minutes_allowed
)
if
problem_is_timed
else
None
)
# because we use self.due and not self.close_date below, this is not the actual end_time, but the
# end_time we want to display to the user
if
self
.
due
and
end_time_to_display
:
end_time_to_display
=
min
(
self
.
due
,
end_time_to_display
)
content
=
{
'name'
:
self
.
display_name_with_default
,
'html'
:
html
,
'weight'
:
self
.
weight
,
...
...
@@ -558,6 +580,9 @@ class CapaModule(CapaFields, XModule):
context
=
{
'problem'
:
content
,
'id'
:
self
.
id
,
'problem_is_timed'
:
problem_is_timed
,
'start_time'
:
self
.
time_started
,
'end_time_to_display'
:
end_time_to_display
,
'check_button'
:
check_button
,
'reset_button'
:
self
.
should_show_reset_button
(),
'save_button'
:
self
.
should_show_save_button
(),
...
...
@@ -642,6 +667,17 @@ class CapaModule(CapaFields, XModule):
return
json
.
dumps
(
result
,
cls
=
ComplexEncoder
)
def
exceeded_time_limit
(
self
):
"""
Has student used up allotted time, if set
"""
if
self
.
minutes_allowed
<=
0
or
not
self
.
time_started
:
return
False
now
=
datetime
.
datetime
.
now
(
UTC
())
# built in hardcoded grace period of 5 min
time_limit_end
=
self
.
time_started
+
datetime
.
timedelta
(
minutes
=
(
self
.
minutes_allowed
+
5
))
return
now
>
time_limit_end
def
is_past_due
(
self
):
"""
Is it now past this problem's due date, including grace period?
...
...
@@ -657,7 +693,8 @@ class CapaModule(CapaFields, XModule):
return
True
if
self
.
is_past_due
():
return
True
if
self
.
exceeded_time_limit
():
return
True
return
False
def
is_submitted
(
self
):
...
...
lms/templates/problem.html
View file @
ef2f20a6
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
from
xmodule
.
util
.
date_utils
import
get_time_display
from
django
.
conf
import
settings
%
>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<h2
class=
"problem-header"
>
...
...
@@ -8,6 +12,20 @@
<section
class=
"problem-progress"
>
</section>
% if problem_is_timed:
<section
class=
"time_limit"
>
<p>
${_("At {start_time}, you started this exam.").format(
start_time=get_time_display(start_time, coerce_tz=settings.TIME_ZONE))}
<br
/>
<b>
${_("By {end_time}, you must manually click the 'Final Submit' button below!").format(
end_time=get_time_display(end_time_to_display, coerce_tz=settings.TIME_ZONE))}
</b>
</p>
</section>
% endif
<section
class=
"problem"
>
${ problem['html'] }
...
...
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