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
681b19d6
Commit
681b19d6
authored
Dec 15, 2014
by
zubair-arbi
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix location revision error for multi parent draft
PLAT-332
parent
da681438
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
+53
-16
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+1
-1
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+52
-15
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
681b19d6
...
@@ -1315,7 +1315,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
...
@@ -1315,7 +1315,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
ancestor_loc
=
parent_loc
ancestor_loc
=
parent_loc
while
ancestor_loc
is
not
None
:
while
ancestor_loc
is
not
None
:
current_loc
=
ancestor_loc
current_loc
=
ancestor_loc
ancestor_loc
=
self
.
_get_raw_parent_location
(
current_loc
,
revision
)
ancestor_loc
=
self
.
_get_raw_parent_location
(
as_published
(
current_loc
)
,
revision
)
if
ancestor_loc
is
None
:
if
ancestor_loc
is
None
:
bulk_record
.
dirty
=
True
bulk_record
.
dirty
=
True
# The parent is an orphan, so remove all the children including
# The parent is an orphan, so remove all the children including
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
681b19d6
...
@@ -979,21 +979,58 @@ class TestMixedModuleStore(CourseComparisonTest):
...
@@ -979,21 +979,58 @@ class TestMixedModuleStore(CourseComparisonTest):
(
child_to_delete_location
,
None
,
ModuleStoreEnum
.
RevisionOption
.
published_only
),
(
child_to_delete_location
,
None
,
ModuleStoreEnum
.
RevisionOption
.
published_only
),
])
])
# Mongo reads:
@ddt.data
(
'draft'
)
# First location:
def
test_get_parent_location_draft
(
self
,
default_ms
):
# - count problem (1)
"""
# - For each level of ancestors: (5)
Test that "get_parent_location" method returns first published parent
# - Count ancestor
for a draft component, if it has many possible parents (including
# - retrieve ancestor
draft parents).
# - compute inheritable data
"""
# Second location:
self
.
initdb
(
default_ms
)
# - load vertical
course_id
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
# - load inheritance data
# create parented children
# TODO: LMS-11220: Document why draft send count is 5
self
.
_create_block_hierarchy
()
# TODO: LMS-11220: Document why draft find count is [19, 6]
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
# TODO: LMS-11220: Document why split find count is [2, 2]
@ddt.data
((
'draft'
,
[
21
,
6
],
0
),
(
'split'
,
[
2
,
2
],
0
))
mongo_store
=
self
.
store
.
_get_modulestore_for_courseid
(
course_id
)
# pylint: disable=protected-access
# add another parent (unit) "vertical_x1b" for problem "problem_x1a_1"
mongo_store
.
collection
.
update
(
self
.
vertical_x1b
.
to_deprecated_son
(
'_id.'
),
{
'$push'
:
{
'definition.children'
:
unicode
(
self
.
problem_x1a_1
)}}
)
# convert first parent (unit) "vertical_x1a" of problem "problem_x1a_1" to draft
self
.
store
.
convert_to_draft
(
self
.
vertical_x1a
,
self
.
user_id
)
item
=
self
.
store
.
get_item
(
self
.
vertical_x1a
)
self
.
assertTrue
(
self
.
store
.
has_published_version
(
item
))
# now problem "problem_x1a_1" has 3 parents [vertical_x1a (draft),
# vertical_x1a (published), vertical_x1b (published)]
# check that "get_parent_location" method of draft branch returns first
# published parent "vertical_x1a" without raising "AssertionError" for
# problem location revision
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
course_id
):
parent
=
mongo_store
.
get_parent_location
(
self
.
problem_x1a_1
)
self
.
assertEqual
(
parent
,
self
.
vertical_x1a
)
# Draft:
# Problem path:
# 1. Get problem
# 2-3. count matches definition.children called 2x?
# 4. get parent via definition.children query
# 5-7. 2 counts and 1 get grandparent via definition.children
# 8-10. ditto for great-grandparent
# 11-13. ditto for next ancestor
# 14. fail count query looking for parent of course (unnecessary)
# 15. get course record direct query (not via definition.children) (already fetched in 13)
# 16. get items for inheritance computation
# 17. get vertical (parent of problem)
# 18. get items for inheritance computation (why? caching should handle)
# 19-20. get vertical_x1b (? why? this is the only ref in trace) & items for inheritance computation
# Chapter path: get chapter, count parents 2x, get parents, count non-existent grandparents
# Split: active_versions & structure
@ddt.data
((
'draft'
,
[
20
,
5
],
0
),
(
'split'
,
[
2
,
2
],
0
))
@ddt.unpack
@ddt.unpack
def
test_path_to_location
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_path_to_location
(
self
,
default_ms
,
num_finds
,
num_sends
):
"""
"""
...
...
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