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
412d86b7
Commit
412d86b7
authored
Oct 07, 2015
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10065 from edx/waheed/plat747-fix-get-courses
Fixed split get_courses.
parents
734e55ea
2dd26a8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+4
-3
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+20
-0
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
412d86b7
...
...
@@ -865,17 +865,18 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
# collect ids and then query for those
version_guids
=
[]
id_version_map
=
{}
id_version_map
=
defaultdict
(
list
)
for
course_index
in
matching_indexes
:
version_guid
=
course_index
[
'versions'
][
branch
]
version_guids
.
append
(
version_guid
)
id_version_map
[
version_guid
]
=
course_index
id_version_map
[
version_guid
]
.
append
(
course_index
)
if
not
version_guids
:
return
for
entry
in
self
.
find_structures_by_id
(
version_guids
):
yield
entry
,
id_version_map
[
entry
[
'_id'
]]
for
course_index
in
id_version_map
[
entry
[
'_id'
]]:
yield
entry
,
course_index
def
_get_structures_for_branch_and_locator
(
self
,
branch
,
locator_factory
,
**
kwargs
):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
412d86b7
...
...
@@ -625,6 +625,26 @@ class SplitModuleCourseTests(SplitModuleTest):
self
.
assertDictEqual
(
course
.
grade_cutoffs
,
{
"Pass"
:
0.45
})
@patch
(
'xmodule.tabs.CourseTab.from_json'
,
side_effect
=
mock_tab_from_json
)
def
test_get_courses_with_same_course_index
(
self
,
_from_json
):
"""
Test that if two courses pointing to same course index,
get_courses should return both.
"""
courses
=
modulestore
()
.
get_courses
(
branch
=
BRANCH_NAME_DRAFT
)
# Should have gotten 3 draft courses.
self
.
assertEqual
(
len
(
courses
),
3
)
course_index
=
modulestore
()
.
get_course_index_info
(
courses
[
0
]
.
id
)
# Creating a new course with same course index of another course.
new_draft_course
=
modulestore
()
.
create_course
(
'testX'
,
'rerun_2.0'
,
'run_q2'
,
1
,
BRANCH_NAME_DRAFT
,
versions_dict
=
course_index
[
'versions'
]
)
courses
=
modulestore
()
.
get_courses
(
branch
=
BRANCH_NAME_DRAFT
)
# Should have gotten 4 draft courses.
self
.
assertEqual
(
len
(
courses
),
4
)
self
.
assertIn
(
new_draft_course
.
id
.
version_agnostic
(),
[
c
.
id
for
c
in
courses
])
@patch
(
'xmodule.tabs.CourseTab.from_json'
,
side_effect
=
mock_tab_from_json
)
def
test_get_org_courses
(
self
,
_from_json
):
courses
=
modulestore
()
.
get_courses
(
branch
=
BRANCH_NAME_DRAFT
,
org
=
'guestx'
)
...
...
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