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
aed29cb0
Commit
aed29cb0
authored
Aug 14, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add get_instance method.
parent
70d5ec6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
13 deletions
+34
-13
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+13
-0
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+21
-13
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
aed29cb0
...
...
@@ -345,6 +345,19 @@ class SplitMongoModuleStore(ModuleStoreBase):
else
:
return
[]
def
get_instance
(
self
,
course_id
,
location
,
depth
=
0
):
"""
Get an instance of this location.
For now, just delegate to get_item and ignore course policy.
depth (int): An argument that some module stores may use to prefetch
descendants of the queried modules for more efficient results later
in the request. The depth is counted in the number of
calls to get_children() to cache. None indicates to cache all descendants.
"""
return
self
.
get_item
(
location
,
depth
=
depth
)
def
get_parent_locations
(
self
,
locator
,
usage_id
=
None
):
'''
Return the locations (Locators w/ usage_ids) for the parents of this location in this
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
aed29cb0
...
...
@@ -327,21 +327,29 @@ class SplitModuleItemTests(SplitModuleTest):
locator
=
BlockUsageLocator
(
version_guid
=
self
.
GUID_D1
,
usage_id
=
'head12345'
)
block
=
modulestore
()
.
get_item
(
locator
)
self
.
assertIsInstance
(
block
,
CourseDescriptor
)
# get_instance just redirects to get_item, ignores course_id
self
.
assertIsInstance
(
modulestore
()
.
get_instance
(
"course_id"
,
locator
),
CourseDescriptor
)
def
verify_greek_hero
(
block
):
self
.
assertEqual
(
block
.
location
.
course_id
,
"GreekHero"
)
# look at this one in detail
self
.
assertEqual
(
len
(
block
.
tabs
),
6
,
"wrong number of tabs"
)
self
.
assertEqual
(
block
.
display_name
,
"The Ancient Greek Hero"
)
self
.
assertEqual
(
block
.
advertised_start
,
"Fall 2013"
)
self
.
assertEqual
(
len
(
block
.
children
),
3
)
self
.
assertEqual
(
block
.
definition_locator
.
definition_id
,
"head12345_12"
)
# check dates and graders--forces loading of descriptor
self
.
assertEqual
(
block
.
edited_by
,
"testassist@edx.org"
)
self
.
assertDictEqual
(
block
.
grade_cutoffs
,
{
"Pass"
:
0.45
},
)
locator
=
BlockUsageLocator
(
course_id
=
'GreekHero'
,
usage_id
=
'head12345'
,
branch
=
'draft'
)
block
=
modulestore
()
.
get_item
(
locator
)
self
.
assertEqual
(
block
.
location
.
course_id
,
"GreekHero"
)
# look at this one in detail
self
.
assertEqual
(
len
(
block
.
tabs
),
6
,
"wrong number of tabs"
)
self
.
assertEqual
(
block
.
display_name
,
"The Ancient Greek Hero"
)
self
.
assertEqual
(
block
.
advertised_start
,
"Fall 2013"
)
self
.
assertEqual
(
len
(
block
.
children
),
3
)
self
.
assertEqual
(
block
.
definition_locator
.
definition_id
,
"head12345_12"
)
# check dates and graders--forces loading of descriptor
self
.
assertEqual
(
block
.
edited_by
,
"testassist@edx.org"
)
self
.
assertDictEqual
(
block
.
grade_cutoffs
,
{
"Pass"
:
0.45
},
)
verify_greek_hero
(
modulestore
()
.
get_item
(
locator
))
# get_instance just redirects to get_item, ignores course_id
verify_greek_hero
(
modulestore
()
.
get_instance
(
"course_id"
,
locator
))
# try to look up other branches
self
.
assertRaises
(
ItemNotFoundError
,
...
...
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