Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
56233672
Commit
56233672
authored
May 15, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for date validation error TIM-575
parent
2b224a74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
apps/openassessment/xblock/resolve_dates.py
+10
-4
apps/openassessment/xblock/test/test_resolve_dates.py
+22
-0
No files found.
apps/openassessment/xblock/resolve_dates.py
View file @
56233672
...
...
@@ -64,11 +64,13 @@ def resolve_dates(start, end, date_ranges):
(The last assessment defaults to the problem end date.)
5) `start` resolves to the earliest start date.
6) `end` resolves to the latest end date.
7) If `start` is later than `end`, move `start` to just before `end`.
7) Ensure that `start` is before `end`.
8) Ensure that `start` is before the earliest due date.
9) Ensure that `end` is after the latest start date.
Overriding start/end dates:
* Rules 5
, 6, and 7
may seem strange, but they're necessary. Unlike `date_ranges`,
* Rules 5
-9
may seem strange, but they're necessary. Unlike `date_ranges`,
the `start` and `end` values are inherited by the XBlock from the LMS.
This means that you can set `start` and `end` in Studio, effectively bypassing
our validation rules.
...
...
@@ -160,9 +162,13 @@ def resolve_dates(start, end, date_ranges):
# defaults. See the docstring above for a more detailed justification.
for
step_start
,
step_end
in
date_ranges
:
if
step_start
is
not
None
:
start
=
min
(
start
,
_parse_date
(
step_start
))
parsed_start
=
_parse_date
(
step_start
)
start
=
min
(
start
,
parsed_start
)
end
=
max
(
end
,
parsed_start
+
dt
.
timedelta
(
milliseconds
=
1
))
if
step_end
is
not
None
:
end
=
max
(
end
,
_parse_date
(
step_end
))
parsed_end
=
_parse_date
(
step_end
)
end
=
max
(
end
,
parsed_end
)
start
=
min
(
start
,
parsed_end
-
dt
.
timedelta
(
milliseconds
=
1
))
# Iterate through the list forwards and backwards simultaneously
# As we iterate forwards, resolve start dates.
...
...
apps/openassessment/xblock/test/test_resolve_dates.py
View file @
56233672
...
...
@@ -97,3 +97,25 @@ class ResolveDatesTest(TestCase):
(
None
,
None
)
]
)
def
test_start_after_step_due
(
self
):
# Bugfix: this should not raise a validation error
resolve_dates
(
"2040-01-01"
,
None
,
[
(
None
,
"2014-08-01"
),
(
None
,
None
),
(
None
,
None
)
]
)
def
test_due_before_step_start
(
self
):
# Bugfix: this should not raise a validation error
resolve_dates
(
None
,
"2001-01-01"
,
[
(
None
,
None
),
(
"2014-02-03"
,
None
),
(
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