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
98c66d90
Commit
98c66d90
authored
Feb 12, 2014
by
Don Mitchell
Committed by
Usman Khalid
Mar 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added get_courses_for_wiki method.
LMS-2136
parent
21db0bff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+9
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+22
-3
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
98c66d90
...
...
@@ -878,6 +878,15 @@ class MongoModuleStore(ModuleStoreWriteBase):
item_locs
-=
all_reachable
return
list
(
item_locs
)
def
get_courses_for_wiki
(
self
,
wiki_slug
):
"""
Return the list of courses which use this wiki
:param wiki_slug: the wiki id
:return: list of course locations
"""
courses
=
self
.
collection
.
find
({
'definition.data.wiki_slug'
:
wiki_slug
})
return
[
Location
(
course
[
'_id'
])
for
course
in
courses
]
def
_create_new_field_data
(
self
,
_category
,
_location
,
definition_data
,
metadata
):
"""
To instantiate a new xmodule which will be saved latter, set up the dbModel and kvs
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
98c66d90
...
...
@@ -37,6 +37,9 @@ RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': ''
class
TestMongoModuleStore
(
object
):
'''Tests!'''
# Explicitly list the courses to load (don't want the big one)
courses
=
[
'toy'
,
'simple'
,
'simple_with_draft'
,
'test_unicode'
]
@classmethod
def
setupClass
(
cls
):
cls
.
connection
=
pymongo
.
MongoClient
(
...
...
@@ -74,9 +77,7 @@ class TestMongoModuleStore(object):
# Also test draft store imports
#
draft_store
=
DraftModuleStore
(
doc_store_config
,
FS_ROOT
,
RENDER_TEMPLATE
,
default_class
=
DEFAULT_CLASS
)
# Explicitly list the courses to load (don't want the big one)
courses
=
[
'toy'
,
'simple'
,
'simple_with_draft'
,
'test_unicode'
]
import_from_xml
(
store
,
DATA_DIR
,
courses
,
draft_store
=
draft_store
,
static_content_store
=
content_store
)
import_from_xml
(
store
,
DATA_DIR
,
TestMongoModuleStore
.
courses
,
draft_store
=
draft_store
,
static_content_store
=
content_store
)
# also test a course with no importing of static content
import_from_xml
(
...
...
@@ -273,6 +274,24 @@ class TestMongoModuleStore(object):
{
'displayname'
:
'hello'
}
)
def
test_get_courses_for_wiki
(
self
):
"""
Test the get_courses_for_wiki method
"""
for
course_id
in
self
.
courses
:
courses
=
self
.
store
.
get_courses_for_wiki
(
course_id
)
assert_equals
(
len
(
courses
),
1
)
assert_equals
(
Location
(
'i4x'
,
'edX'
,
course_id
,
'course'
,
'2012_Fall'
),
courses
[
0
])
course_locs
=
self
.
store
.
get_courses_for_wiki
(
'no_such_wiki'
)
assert_equals
(
len
(
course_locs
),
0
)
# now set two to have same wiki
course
=
self
.
store
.
get_course
(
'edX/toy/2012_Fall'
)
course
.
wiki_slug
=
'simple'
self
.
store
.
save_xmodule
(
course
)
courses
=
self
.
store
.
get_courses_for_wiki
(
'simple'
)
assert_equals
(
len
(
courses
),
2
)
for
course_id
in
[
'toy'
,
'simple'
]:
assert_in
(
Location
(
'i4x'
,
'edX'
,
course_id
,
'course'
,
'2012_Fall'
),
courses
)
class
TestMongoKeyValueStore
(
object
):
"""
...
...
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