From abcdc05af4613b250850f959055033bd50800955 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Mon, 13 Jul 2015 11:10:57 -0400 Subject: [PATCH 1/2] Return just the CourseDescriptor in discussions get_course() Instead of calling the modulestore's get_course(), return the descriptor via self.runtime.get_block(). Doing this means that bulk ops caching works within CCX courses. Note: The long term fix for this is to have some course-level scope so that we're not peeking at the top of the tree just for some basic discussion-specific configuration information (in this case the blackout dates). TNL-2697 --- common/lib/xmodule/xmodule/discussion_module.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/discussion_module.py b/common/lib/xmodule/xmodule/discussion_module.py index ed787fb296..0d2d29b6c1 100644 --- a/common/lib/xmodule/xmodule/discussion_module.py +++ b/common/lib/xmodule/xmodule/discussion_module.py @@ -66,9 +66,11 @@ class DiscussionModule(DiscussionFields, XModule): def get_course(self): """ - Return course by course id. + Return the CourseDescriptor by course id. """ - return self.descriptor.runtime.modulestore.get_course(self.course_id) + course_key = self.location.course_key + root_course_loc = course_key.make_usage_key(u'course', u'course') + return self.runtime.get_block(root_course_loc) class DiscussionDescriptor(DiscussionFields, MetadataOnlyEditingDescriptor, RawDescriptor): From 693901529c0ec4672785b73d618eba59be55a41f Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Mon, 13 Jul 2015 17:54:01 -0400 Subject: [PATCH 2/2] Instead of calculating the course's usage key, just follow the parent chain. --- common/lib/xmodule/xmodule/discussion_module.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/discussion_module.py b/common/lib/xmodule/xmodule/discussion_module.py index 0d2d29b6c1..157f6141e2 100644 --- a/common/lib/xmodule/xmodule/discussion_module.py +++ b/common/lib/xmodule/xmodule/discussion_module.py @@ -66,11 +66,13 @@ class DiscussionModule(DiscussionFields, XModule): def get_course(self): """ - Return the CourseDescriptor by course id. + Return the CourseDescriptor at the root of the tree we're in. """ - course_key = self.location.course_key - root_course_loc = course_key.make_usage_key(u'course', u'course') - return self.runtime.get_block(root_course_loc) + block = self + while block.parent: + block = block.get_parent() + + return block class DiscussionDescriptor(DiscussionFields, MetadataOnlyEditingDescriptor, RawDescriptor):