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
7ba87555
Commit
7ba87555
authored
Sep 04, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #623 from edx/split/edit_info
Don't use published_date to figure out if xblock is published
parents
7ddfac0b
bdcb9eae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
21 deletions
+30
-21
openassessment/xblock/openassessmentblock.py
+4
-1
openassessment/xblock/test/test_openassessment.py
+13
-14
openassessment/xblock/test/test_studio.py
+13
-6
No files found.
openassessment/xblock/openassessmentblock.py
View file @
7ba87555
...
...
@@ -639,7 +639,10 @@ class OpenAssessmentBlock(
bool
"""
# By default, assume that we're published, in case the runtime doesn't support publish date.
is_published
=
getattr
(
self
,
'published_date'
,
True
)
is
not
None
if
hasattr
(
self
.
runtime
,
'modulestore'
):
is_published
=
self
.
runtime
.
modulestore
.
has_published_version
(
self
)
else
:
is_published
=
True
is_closed
,
reason
,
__
,
__
=
self
.
is_closed
(
step
=
step
)
return
is_published
and
(
not
is_closed
or
reason
==
'due'
)
...
...
openassessment/xblock/test/test_openassessment.py
View file @
7ba87555
...
...
@@ -4,7 +4,7 @@ Tests the Open Assessment XBlock functionality.
from
collections
import
namedtuple
import
datetime
as
dt
import
pytz
from
mock
import
Mock
,
patch
from
mock
import
Mock
,
patch
,
MagicMock
from
openassessment.xblock
import
openassessmentblock
from
openassessment.xblock.resolve_dates
import
DISTANT_PAST
,
DISTANT_FUTURE
...
...
@@ -395,23 +395,22 @@ class TestDates(XBlockHandlerTestCase):
@scenario
(
'data/basic_scenario.xml'
)
def
test_is_released_unpublished
(
self
,
xblock
):
# Simulate the runtime published_date mixin field
# The scenario doesn't provide a start date, so `is_released()`
# should be controlled only by the published date.
xblock
.
published_date
=
None
# should be controlled only by the published state.
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
self
.
assertFalse
(
xblock
.
is_released
())
@scenario
(
'data/basic_scenario.xml'
)
def
test_is_released_published
(
self
,
xblock
):
# Simulate the runtime published_date mixin field
# The scenario doesn't provide a start date, so `is_released()`
# should be controlled only by the published date.
xblock
.
published_date
=
dt
.
datetime
(
2013
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
# should be controlled only by the published state which defaults to True
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
True
self
.
assertTrue
(
xblock
.
is_released
())
@scenario
(
'data/basic_scenario.xml'
)
def
test_is_released_no_published_date_field
(
self
,
xblock
):
# If the runtime doesn't provide a published_date field, assume we've been published
def
test_is_released_no_ms
(
self
,
xblock
):
self
.
assertTrue
(
xblock
.
is_released
())
@scenario
(
'data/basic_scenario.xml'
)
...
...
@@ -419,14 +418,14 @@ class TestDates(XBlockHandlerTestCase):
# Simulate being course staff
xblock
.
xmodule_runtime
=
Mock
(
user_is_staff
=
True
)
# Not published, should be not released
xblock
.
published_date
=
None
self
.
assertFalse
(
xblock
.
is_released
())
# Published, should be released
xblock
.
published_date
=
dt
.
datetime
(
2013
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
self
.
assertTrue
(
xblock
.
is_released
())
# Not published, should be not released
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
self
.
assertFalse
(
xblock
.
is_released
())
@scenario
(
'data/staff_dates_scenario.xml'
)
def
test_course_staff_dates
(
self
,
xblock
):
...
...
openassessment/xblock/test/test_studio.py
View file @
7ba87555
...
...
@@ -7,6 +7,7 @@ import json
import
datetime
as
dt
import
pytz
from
ddt
import
ddt
,
file_data
from
mock
import
MagicMock
from
.base
import
scenario
,
XBlockHandlerTestCase
...
...
@@ -125,7 +126,8 @@ class StudioViewTest(XBlockHandlerTestCase):
@file_data
(
'data/update_xblock.json'
)
@scenario
(
'data/basic_scenario.xml'
)
def
test_update_editor_context
(
self
,
xblock
,
data
):
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
resp
=
self
.
request
(
xblock
,
'update_editor_context'
,
json
.
dumps
(
data
),
response_format
=
'json'
)
self
.
assertTrue
(
resp
[
'success'
],
msg
=
resp
.
get
(
'msg'
))
...
...
@@ -143,7 +145,8 @@ class StudioViewTest(XBlockHandlerTestCase):
"peer-assessment"
,
"self-assessment"
,
]
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
resp
=
self
.
request
(
xblock
,
'update_editor_context'
,
json
.
dumps
(
data
),
response_format
=
'json'
)
self
.
assertTrue
(
resp
[
'success'
],
msg
=
resp
.
get
(
'msg'
))
self
.
assertEqual
(
xblock
.
editor_assessments_order
,
data
[
'editor_assessments_order'
])
...
...
@@ -163,7 +166,8 @@ class StudioViewTest(XBlockHandlerTestCase):
"peer-assessment"
,
"self-assessment"
,
]
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
resp
=
self
.
request
(
xblock
,
'update_editor_context'
,
json
.
dumps
(
data
),
response_format
=
'json'
)
self
.
assertTrue
(
resp
[
'success'
],
msg
=
resp
.
get
(
'msg'
))
self
.
assertEqual
(
xblock
.
editor_assessments_order
,
data
[
'editor_assessments_order'
])
...
...
@@ -172,7 +176,8 @@ class StudioViewTest(XBlockHandlerTestCase):
def
test_update_editor_context_saves_leaderboard
(
self
,
xblock
):
data
=
copy
.
deepcopy
(
self
.
UPDATE_EDITOR_DATA
)
data
[
'leaderboard_show'
]
=
42
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
resp
=
self
.
request
(
xblock
,
'update_editor_context'
,
json
.
dumps
(
data
),
response_format
=
'json'
)
self
.
assertTrue
(
resp
[
'success'
],
msg
=
resp
.
get
(
'msg'
))
self
.
assertEqual
(
xblock
.
leaderboard_show
,
42
)
...
...
@@ -187,7 +192,8 @@ class StudioViewTest(XBlockHandlerTestCase):
else
:
expected_error
=
'error updating xblock configuration'
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
resp
=
self
.
request
(
xblock
,
'update_editor_context'
,
json
.
dumps
(
data
),
response_format
=
'json'
)
self
.
assertFalse
(
resp
[
'success'
])
self
.
assertIn
(
expected_error
,
resp
[
'msg'
]
.
lower
())
...
...
@@ -225,7 +231,8 @@ class StudioViewTest(XBlockHandlerTestCase):
self
.
assertIn
(
'msg'
,
resp
)
# Set the problem to unpublished with a start date in the future
xblock
.
published_date
=
None
xblock
.
runtime
.
modulestore
=
MagicMock
()
xblock
.
runtime
.
modulestore
.
has_published_version
.
return_value
=
False
xblock
.
start
=
dt
.
datetime
(
3000
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
resp
=
self
.
request
(
xblock
,
'check_released'
,
json
.
dumps
(
""
),
response_format
=
'json'
)
self
.
assertTrue
(
resp
[
'success'
])
...
...
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