From 94d3ccf674a8333809d31fd2ca5c2462258ef28f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 19 Mar 2013 10:41:12 -0400 Subject: [PATCH 1/3] Always compute the metadata inheritance tree, even on a course module, so that when walking down the tree, we always get the right data --- common/lib/xmodule/xmodule/modulestore/mongo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index c5e5bbfdf8..88a4933084 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -391,8 +391,7 @@ class MongoModuleStore(ModuleStoreBase): # if we are loading a course object, there is no parent to inherit the metadata from # so don't bother getting it - if item['location']['category'] != 'course': - metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) + metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) # TODO (cdodge): When the 'split module store' work has been completed, we should remove # the 'metadata_inheritance_tree' parameter From 0209c883bb8256acb86c320da306c1183c23a6d1 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 19 Mar 2013 10:41:38 -0400 Subject: [PATCH 2/3] Remove trailing whitespace --- common/lib/xmodule/xmodule/modulestore/mongo.py | 7 ++++--- lms/djangoapps/courseware/grades.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index 88a4933084..95b74bf625 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -303,6 +303,7 @@ class MongoModuleStore(ModuleStoreBase): # this is likely a leaf node, so let's record what metadata we need to inherit metadata_to_inherit[child] = my_metadata + if root is not None: _compute_inherited_metadata(root) @@ -330,7 +331,7 @@ class MongoModuleStore(ModuleStoreBase): return tree def clear_cached_metadata_inheritance_tree(self, location): - key_name = '{0}/{1}'.format(location.org, location.course) + key_name = '{0}/{1}'.format(location.org, location.course) if self.metadata_inheritance_cache is not None: self.metadata_inheritance_cache.delete(key_name) @@ -611,7 +612,7 @@ class MongoModuleStore(ModuleStoreBase): self._update_single_item(location, {'metadata': metadata}) # recompute (and update) the metadata inheritance tree which is cached - self.get_cached_metadata_inheritance_tree(loc, force_refresh = True) + self.get_cached_metadata_inheritance_tree(loc, force_refresh = True) def delete_item(self, location): """ @@ -631,7 +632,7 @@ class MongoModuleStore(ModuleStoreBase): self.collection.remove({'_id': Location(location).dict()}) # recompute (and update) the metadata inheritance tree which is cached - self.get_cached_metadata_inheritance_tree(Location(location), force_refresh = True) + self.get_cached_metadata_inheritance_tree(Location(location), force_refresh = True) def get_parent_locations(self, location, course_id): diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index ecff14777d..e7f389696c 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -159,6 +159,7 @@ def grade(student, request, course, model_data_cache=None, keep_raw_scores=False # If we haven't seen a single problem in the section, we don't have to grade it at all! We can assume 0% for moduledescriptor in section['xmoduledescriptors']: # Create a fake key to pull out a StudentModule object from the ModelDataCache + key = LmsKeyValueStore.Key( Scope.student_state, student.id, From 8fda5af4e4ec01fc0f4870e6b259963d6fa9dd91 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 19 Mar 2013 10:54:46 -0400 Subject: [PATCH 3/3] Comment cleanup --- common/lib/xmodule/xmodule/modulestore/mongo.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index 95b74bf625..aceebbf15f 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -388,10 +388,6 @@ class MongoModuleStore(ModuleStoreBase): resource_fs = OSFS(root) - metadata_inheritance_tree = None - - # if we are loading a course object, there is no parent to inherit the metadata from - # so don't bother getting it metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) # TODO (cdodge): When the 'split module store' work has been completed, we should remove