Commit 258d3227 by Christina Roberts

Merge pull request #1938 from edx/christina/common-location

Create explicit Locations.
parents e326fd13 df09e99a
......@@ -724,7 +724,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
# @hack! We need to find the course location however, we don't
# know the 'name' parameter in this context, so we have
# to assume there's only one item in this query even though we are not specifying a name
course_search_location = ['i4x', location.org, location.course, 'course', None]
course_search_location = Location('i4x', location.org, location.course, 'course', None)
courses = self.get_items(course_search_location, depth=depth)
# make sure we found exactly one match on this above course search
......
......@@ -182,15 +182,15 @@ class TestMixedModuleStore(object):
)
def test_get_items(self):
modules = self.store.get_items(['i4x', None, None, 'course', None], IMPORT_COURSEID)
modules = self.store.get_items(Location('i4x', None, None, 'course', None), IMPORT_COURSEID)
assert_equals(len(modules), 1)
assert_equals(modules[0].location.course, self.import_course)
modules = self.store.get_items(['i4x', None, None, 'course', None], XML_COURSEID1)
modules = self.store.get_items(Location('i4x', None, None, 'course', None), XML_COURSEID1)
assert_equals(len(modules), 1)
assert_equals(modules[0].location.course, 'toy')
modules = self.store.get_items(['i4x', None, None, 'course', None], XML_COURSEID2)
modules = self.store.get_items(Location('i4x', None, None, 'course', None), XML_COURSEID2)
assert_equals(len(modules), 1)
assert_equals(modules[0].location.course, 'simple')
......
......@@ -79,7 +79,7 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
module = render.get_module(
self.mock_user,
mock_request,
['i4x', 'edX', 'toy', 'html', 'toyjumpto'],
Location('i4x', 'edX', 'toy', 'html', 'toyjumpto'),
field_data_cache,
self.course_id
)
......
......@@ -388,7 +388,7 @@ def jump_to_id(request, course_id, module_id):
course_location = CourseDescriptor.id_to_location(course_id)
items = modulestore().get_items(
['i4x', course_location.org, course_location.course, None, module_id],
Location('i4x', course_location.org, course_location.course, None, module_id),
course_id=course_id
)
......
......@@ -16,6 +16,7 @@ import edxmako
import pystache_custom as pystache
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import Location
from django.utils.timezone import UTC
log = logging.getLogger(__name__)
......@@ -56,7 +57,7 @@ def has_forum_access(uname, course_id, rolename):
def _get_discussion_modules(course):
all_modules = modulestore().get_items(
['i4x', course.location.org, course.location.course, 'discussion', None],
Location('i4x', course.location.org, course.location.course, 'discussion', None),
course_id=course.id
)
......
......@@ -16,7 +16,8 @@ import open_ended_notifications
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import search
from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem
from xmodule.modulestore import Location
from xmodule.modulestore.exceptions import NoPathToItem
from django.http import HttpResponse, Http404, HttpResponseRedirect
from edxmako.shortcuts import render_to_string
......@@ -92,7 +93,7 @@ def find_peer_grading_module(course):
# Get the course id and split it.
course_id_parts = course.id.split("/")
# Get the peer grading modules currently in the course. Explicitly specify the course id to avoid issues with different runs.
items = modulestore().get_items(['i4x', course_id_parts[0], course_id_parts[1], 'peergrading', None],
items = modulestore().get_items(Location('i4x', course_id_parts[0], course_id_parts[1], 'peergrading', None),
course_id=course.id)
#See if any of the modules are centralized modules (ie display info from multiple problems)
items = [i for i in items if not getattr(i, "use_for_single_location", True)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment