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
d77fe6e5
Commit
d77fe6e5
authored
Aug 25, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4881 from edx/dhm/get_children_agnostic
Split get_block uses the passed in id rather than constructed
parents
e4aaf497
ad8ece51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
common/lib/xmodule/xmodule/modulestore/search.py
+4
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py
+22
-13
No files found.
common/lib/xmodule/xmodule/modulestore/search.py
View file @
d77fe6e5
...
...
@@ -95,10 +95,12 @@ def path_to_location(modulestore, usage_key):
category
=
path
[
path_index
]
.
block_type
if
category
==
'sequential'
or
category
==
'videosequence'
:
section_desc
=
modulestore
.
get_item
(
path
[
path_index
])
child_locs
=
[
c
.
location
.
block_id
for
c
in
section_desc
.
get_children
()]
# this calls get_children rather than just children b/c old mongo includes private children
# in children but not in get_children
child_locs
=
[
c
.
location
for
c
in
section_desc
.
get_children
()]
# positions are 1-indexed, and should be strings to be consistent with
# url parsing.
position_list
.
append
(
str
(
child_locs
.
index
(
path
[
path_index
+
1
]
.
block_id
)
+
1
))
position_list
.
append
(
str
(
child_locs
.
index
(
path
[
path_index
+
1
])
+
1
))
position
=
"_"
.
join
(
position_list
)
return
(
course_id
,
chapter
,
section
,
position
)
common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py
View file @
d77fe6e5
...
...
@@ -53,15 +53,18 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
self
.
default_class
=
default_class
self
.
local_modules
=
{}
def
_load_item
(
self
,
block_id
,
course_entry_override
=
None
,
**
kwargs
):
if
isinstance
(
block_id
,
BlockUsageLocator
):
if
isinstance
(
block_id
.
block_id
,
LocalId
):
def
_load_item
(
self
,
usage_key
,
course_entry_override
=
None
,
**
kwargs
):
# usage_key is either a UsageKey or just the block_id. if a usage_key,
if
isinstance
(
usage_key
,
BlockUsageLocator
):
if
isinstance
(
usage_key
.
block_id
,
LocalId
):
try
:
return
self
.
local_modules
[
block_id
]
return
self
.
local_modules
[
usage_key
]
except
KeyError
:
raise
ItemNotFoundError
else
:
block_id
=
block_id
.
block_id
block_id
=
usage_key
.
block_id
else
:
block_id
=
usage_key
json_data
=
self
.
module_data
.
get
(
block_id
)
if
json_data
is
None
:
...
...
@@ -77,7 +80,12 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
raise
ItemNotFoundError
(
block_id
)
class_
=
self
.
load_block_type
(
json_data
.
get
(
'category'
))
return
self
.
xblock_from_json
(
class_
,
block_id
,
json_data
,
course_entry_override
,
**
kwargs
)
new_item
=
self
.
xblock_from_json
(
class_
,
block_id
,
json_data
,
course_entry_override
,
**
kwargs
)
if
isinstance
(
usage_key
,
BlockUsageLocator
):
# trust the passed in key to know the caller's expectations of which fields are filled in.
# particularly useful for strip_keys so may go away when we're version aware
new_item
.
location
=
usage_key
return
new_item
# xblock's runtime does not always pass enough contextual information to figure out
# which named container (course x branch) or which parent is requesting an item. Because split allows
...
...
@@ -107,14 +115,15 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
if
block_id
is
None
:
block_id
=
LocalId
()
block_course_key
=
CourseLocator
(
version_guid
=
course_entry_override
[
'structure'
][
'_id'
],
org
=
course_entry_override
.
get
(
'org'
),
course
=
course_entry_override
.
get
(
'course'
),
run
=
course_entry_override
.
get
(
'run'
),
branch
=
course_entry_override
.
get
(
'branch'
),
)
block_locator
=
BlockUsageLocator
(
CourseLocator
(
version_guid
=
course_entry_override
[
'structure'
][
'_id'
],
org
=
course_entry_override
.
get
(
'org'
),
course
=
course_entry_override
.
get
(
'course'
),
run
=
course_entry_override
.
get
(
'run'
),
branch
=
course_entry_override
.
get
(
'branch'
),
),
block_course_key
,
block_type
=
json_data
.
get
(
'category'
),
block_id
=
block_id
,
)
...
...
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