Merge pull request #8768 from open-craft/jump_to_children_ospr
Jump to children
This commit is contained in:
@@ -44,8 +44,8 @@ def path_to_location(modulestore, usage_key):
|
||||
|
||||
If no path exists, return None.
|
||||
|
||||
If a path exists, return it as a list with target location first, and
|
||||
the starting location last.
|
||||
If a path exists, return it as a tuple with root location first, and
|
||||
the target location last.
|
||||
'''
|
||||
# Standard DFS
|
||||
|
||||
@@ -86,6 +86,7 @@ def path_to_location(modulestore, usage_key):
|
||||
# pull out the location names
|
||||
chapter = path[1].name if n > 1 else None
|
||||
section = path[2].name if n > 2 else None
|
||||
vertical = path[3].name if n > 3 else None
|
||||
# Figure out the position
|
||||
position = None
|
||||
|
||||
@@ -109,7 +110,7 @@ def path_to_location(modulestore, usage_key):
|
||||
position_list.append(str(child_locs.index(path[path_index + 1]) + 1))
|
||||
position = "_".join(position_list)
|
||||
|
||||
return (course_id, chapter, section, position)
|
||||
return (course_id, chapter, section, vertical, position, path[-1])
|
||||
|
||||
|
||||
def navigation_index(position):
|
||||
|
||||
@@ -1221,15 +1221,16 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
|
||||
|
||||
should_work = (
|
||||
(self.problem_x1a_2,
|
||||
(course_key, u"Chapter_x", u"Sequential_x1", '1')),
|
||||
(course_key, u"Chapter_x", u"Sequential_x1", u'Vertical_x1a', '1', self.problem_x1a_2)),
|
||||
(self.chapter_x,
|
||||
(course_key, "Chapter_x", None, None)),
|
||||
(course_key, "Chapter_x", None, None, None, self.chapter_x)),
|
||||
)
|
||||
|
||||
for location, expected in should_work:
|
||||
# each iteration has different find count, pop this iter's find count
|
||||
with check_mongo_calls(num_finds.pop(0), num_sends):
|
||||
self.assertEqual(path_to_location(self.store, location), expected)
|
||||
path = path_to_location(self.store, location)
|
||||
self.assertEqual(path, expected)
|
||||
|
||||
not_found = (
|
||||
course_key.make_usage_key('video', 'WelcomeX'),
|
||||
@@ -1259,11 +1260,13 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
|
||||
# only needs course_locations set
|
||||
self.initdb('draft')
|
||||
course_key = self.course_locations[self.XML_COURSEID1].course_key
|
||||
video_key = course_key.make_usage_key('video', 'Welcome')
|
||||
chapter_key = course_key.make_usage_key('chapter', 'Overview')
|
||||
should_work = (
|
||||
(course_key.make_usage_key('video', 'Welcome'),
|
||||
(course_key, "Overview", "Welcome", None)),
|
||||
(course_key.make_usage_key('chapter', 'Overview'),
|
||||
(course_key, "Overview", None, None)),
|
||||
(video_key,
|
||||
(course_key, "Overview", "Welcome", None, None, video_key)),
|
||||
(chapter_key,
|
||||
(course_key, "Overview", None, None, None, chapter_key)),
|
||||
)
|
||||
|
||||
for location, expected in should_work:
|
||||
|
||||
Reference in New Issue
Block a user