From 9ac57c87c6c56371181092635a5881634b34b517 Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Fri, 4 Feb 2022 12:57:16 +0500 Subject: [PATCH 1/2] Added Investigation logs near and in ImportSystem.process_xml --- common/lib/xmodule/xmodule/modulestore/xml.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index c84c7be722ee..6499a6f84c7e 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -167,8 +167,12 @@ def fallback_name(orig_name=None): None, # parent_id id_manager, ) + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Descriptor {descriptor}") except Exception as err: # pylint: disable=broad-except if not self.load_error_modules: + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Exception error loading modules") raise # Didn't load properly. Fall back on loading as an error @@ -198,6 +202,8 @@ def fallback_name(orig_name=None): descriptor.data_dir = course_dir if descriptor.scope_ids.usage_id in xmlstore.modules[course_id]: + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Descriptor.scope_ids.usage_id in xmlstore.modules[{target_course_id}]") # keep the parent pointer if any but allow everything else to overwrite other_copy = xmlstore.modules[course_id][descriptor.scope_ids.usage_id] descriptor.parent = other_copy.parent @@ -206,6 +212,8 @@ def fallback_name(orig_name=None): xmlstore.modules[course_id][descriptor.scope_ids.usage_id] = descriptor if descriptor.has_children: + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Descriptor has children") for child in descriptor.get_children(): # parent is alphabetically least if child.parent is None or child.parent > descriptor.scope_ids.usage_id: @@ -214,7 +222,11 @@ def fallback_name(orig_name=None): # After setting up the descriptor, save any changes that we have # made to attributes on the descriptor to the underlying KeyValueStore. + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Saving Descriptor") descriptor.save() + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Descriptor Saved") return descriptor render_template = lambda template, context: '' @@ -505,6 +517,8 @@ def get_policy(usage_id): if self.user_service: services['user'] = self.user_service + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Beginning Import System") system = ImportSystem( xmlstore=self, course_id=course_id, @@ -519,9 +533,15 @@ def get_policy(usage_id): services=services, target_course_id=target_course_id, ) + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Import System Completed. Starting to process XML") course_descriptor = system.process_xml(etree.tostring(course_data, encoding='unicode')) + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : XML Processed. Course Descriptor {course_descriptor}") # If we fail to load the course, then skip the rest of the loading steps if isinstance(course_descriptor, ErrorBlock): + if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": + log.info(f"Investigation Log: {target_course_id} : Course Descriptor is instance of ErrorBlock") return course_descriptor self.content_importers(system, course_descriptor, course_dir, url_name) From d508a4ba04bcfbd23610fd0b1d7ca492faac0c79 Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Fri, 4 Feb 2022 14:57:24 +0500 Subject: [PATCH 2/2] Added parent description in log while saving descriptor --- common/lib/xmodule/xmodule/modulestore/xml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 6499a6f84c7e..d7a95532d682 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -223,10 +223,10 @@ def fallback_name(orig_name=None): # After setting up the descriptor, save any changes that we have # made to attributes on the descriptor to the underlying KeyValueStore. if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": - log.info(f"Investigation Log: {target_course_id} : Saving Descriptor") + log.info(f"Investigation Log: {target_course_id} : Saving Descriptor with parent {descriptor.parent}") descriptor.save() if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": - log.info(f"Investigation Log: {target_course_id} : Descriptor Saved") + log.info(f"Investigation Log: {target_course_id} : Descriptor Saved with parent {descriptor.parent}") return descriptor render_template = lambda template, context: ''