diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 9e655fa7b3..bb35c8ee08 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -110,7 +110,7 @@ def edit_item(request): lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format( lms_base=settings.LMS_BASE, # TODO: These will need to be changed to point to the particular instance of this problem in the particular course - course_id=[course.id for course in modulestore().get_courses() if course.location.org == item.location.org and course.location.course == item.location.course][0], + course_id=modulestore().get_containing_courses()[0].id, location=item.location, ) else: diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 9d51ab7207..fae4ff0eac 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -338,7 +338,6 @@ class ModuleStore(object): ''' raise NotImplementedError - def get_parent_locations(self, location): '''Find all locations that are the parents of this location. Needed for path_to_location(). @@ -347,6 +346,22 @@ class ModuleStore(object): ''' raise NotImplementedError + def get_containing_courses(self, location): + ''' + Returns the list of courses that contains the specified location + + TODO (cpennington): This should really take a module instance id, + rather than a location + ''' + courses = [ + course + for course in self.get_courses() + if course.location.org == location.org + and course.location.course == location.course + ] + + return courses + class ModuleStoreBase(ModuleStore): '''