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
OpenEdx
edx-platform
Commits
fc1ca7b3
Commit
fc1ca7b3
authored
Mar 03, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No longer create loc maps on create_(item|course)
parent
dcc6f544
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
93 deletions
+64
-93
common/lib/xmodule/xmodule/modulestore/locator.py
+0
-4
common/lib/xmodule/xmodule/modulestore/mixed.py
+44
-72
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+11
-4
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+9
-13
No files found.
common/lib/xmodule/xmodule/modulestore/locator.py
View file @
fc1ca7b3
...
...
@@ -441,8 +441,6 @@ class BlockUsageLocator(CourseLocator):
Returns a copy of itself without any version info.
:raises: ValueError if the block locator has no package_id
:param block_locator:
"""
return
BlockUsageLocator
(
package_id
=
self
.
package_id
,
branch
=
self
.
branch
,
...
...
@@ -454,8 +452,6 @@ class BlockUsageLocator(CourseLocator):
Returns a copy of itself without any course info.
:raises: ValueError if the block locator has no version_guid
:param block_locator:
"""
return
BlockUsageLocator
(
version_guid
=
self
.
version_guid
,
block_id
=
self
.
block_id
)
...
...
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
fc1ca7b3
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
fc1ca7b3
...
...
@@ -625,12 +625,19 @@ class MongoModuleStore(ModuleStoreWriteBase):
modules
=
self
.
_load_items
(
list
(
items
),
depth
)
return
modules
def
create_course
(
self
,
location
,
definition_data
=
None
,
metadata
=
None
,
runtime
=
None
):
def
create_course
(
self
,
course_id
,
definition_data
=
None
,
metadata
=
None
,
runtime
=
None
):
"""
Create a course with the given
location. The location category must be 'course'
.
Create a course with the given
course_id
.
"""
if
location
.
category
!=
'course'
:
raise
ValueError
(
u"Course roots must be of category 'course': {}"
.
format
(
unicode
(
location
)))
if
isinstance
(
course_id
,
Location
):
location
=
course_id
if
location
.
category
!=
'course'
:
raise
ValueError
(
u"Course roots must be of category 'course': {}"
.
format
(
unicode
(
location
)))
else
:
course_dict
=
Location
.
parse_course_id
(
course_id
)
course_dict
[
'category'
]
=
'course'
course_dict
[
'tag'
]
=
'i4x'
location
=
Location
(
course_dict
)
return
self
.
create_and_save_xmodule
(
location
,
definition_data
,
metadata
,
runtime
)
def
create_xmodule
(
self
,
location
,
definition_data
=
None
,
metadata
=
None
,
system
=
None
,
fields
=
{}):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
fc1ca7b3
...
...
@@ -110,25 +110,23 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
addCleanup
(
patcher
.
stop
)
self
.
addTypeEqualityFunc
(
BlockUsageLocator
,
'_compareIgnoreVersion'
)
def
_create_course
(
self
,
default
,
course_
location
,
item_location
):
def
_create_course
(
self
,
default
,
course_
id
):
"""
Create a course w/ one item in the persistence store using the given course & item location.
NOTE: course_location and item_location must be Location regardless of the app reference type in order
to cause the right mapping to be created.
"""
course
=
self
.
store
.
create_course
(
course_location
,
store_name
=
default
,
metadata
=
{
'display_name'
:
course_location
.
name
}
)
course
=
self
.
store
.
create_course
(
course_id
,
store_name
=
default
)
category
=
self
.
import_chapter_location
.
category
block_id
=
self
.
import_chapter_location
.
name
chapter
=
self
.
store
.
create_item
(
# don't use course_location as it may not be the repr
course
.
location
,
item_location
.
category
,
location
=
item_location
,
block_id
=
item_location
.
name
course
.
location
,
category
,
location
=
self
.
import_chapter_location
,
block_id
=
block_id
)
if
isinstance
(
course
.
location
,
CourseLocator
):
self
.
course_locations
[
self
.
MONGO_COURSEID
]
=
course
.
location
.
version_agnostic
()
self
.
import_chapter_location
=
chapter
.
location
.
version_agnostic
()
else
:
self
.
assertEqual
(
course
.
location
,
course_location
)
self
.
assertEqual
(
chapter
.
location
,
item
_location
)
self
.
assertEqual
(
course
.
location
.
course_id
,
course_id
)
self
.
assertEqual
(
chapter
.
location
,
self
.
import_chapter
_location
)
def
initdb
(
self
,
default
):
"""
...
...
@@ -159,13 +157,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
xml_chapter_location
=
self
.
course_locations
[
self
.
XML_COURSEID1
]
.
replace
(
category
=
'chapter'
,
name
=
'Overview'
)
# grab old style location b4 possibly converted
import_location
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
# get Locators and set up the loc mapper if app is Locator based
if
default
==
'split'
:
self
.
fake_location
=
loc_mapper
()
.
translate_location
(
'foo/bar/2012_Fall'
,
self
.
fake_location
)
self
.
_create_course
(
default
,
import_location
,
self
.
import_chapter_location
)
self
.
_create_course
(
default
,
self
.
MONGO_COURSEID
)
@ddt.data
(
'direct'
,
'split'
)
def
test_get_modulestore_type
(
self
,
default_ms
):
...
...
@@ -273,12 +269,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
initdb
(
default_ms
)
# we should have 3 total courses across all stores
courses
=
self
.
store
.
get_courses
()
self
.
assertEqual
(
len
(
courses
),
3
)
course_ids
=
[
course
.
location
.
version_agnostic
()
if
hasattr
(
course
.
location
,
'version_agnostic'
)
else
course
.
location
for
course
in
courses
]
self
.
assertEqual
(
len
(
courses
),
3
,
"Not 3 courses: {}"
.
format
(
course_ids
))
self
.
assertIn
(
self
.
course_locations
[
self
.
MONGO_COURSEID
],
course_ids
)
self
.
assertIn
(
self
.
course_locations
[
self
.
XML_COURSEID1
],
course_ids
)
self
.
assertIn
(
self
.
course_locations
[
self
.
XML_COURSEID2
],
course_ids
)
...
...
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