Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Investigation logs near and in ImportSystem.process_xml #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions common/lib/xmodule/xmodule/modulestore/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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 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 with parent {descriptor.parent}")
return descriptor

render_template = lambda template, context: ''
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down