From 66655080f6cf0755c80dc8e7a5bf7d9326f89ef5 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Fri, 6 Sep 2013 11:12:10 -0400 Subject: [PATCH] Log a warning if assumption about path is not correct. --- lms/djangoapps/open_ended_grading/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/open_ended_grading/utils.py b/lms/djangoapps/open_ended_grading/utils.py index daca73da4a..15aaf0246f 100644 --- a/lms/djangoapps/open_ended_grading/utils.py +++ b/lms/djangoapps/open_ended_grading/utils.py @@ -1,6 +1,9 @@ from xmodule.modulestore import search from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem +import logging + +log = logging.getLogger(__name__) def does_location_exist(course_id, location): """ @@ -12,8 +15,13 @@ def does_location_exist(course_id, location): search.path_to_location(modulestore(), course_id, location) return True except ItemNotFoundError: - # If the problem cannot be found at the location received from the grading controller server, it has been deleted by the course author. + # If the problem cannot be found at the location received from the grading controller server, + # it has been deleted by the course author. return False except NoPathToItem: - # If the problem can be found, but there is no path to it, then it is a draft. + # If the problem can be found, but there is no path to it, then we assume it is a draft. + # Log a warning if the problem is not a draft (location does not end in "draft"). + if not location.endswith("draft"): + log.warn(("Got an unexpected NoPathToItem error in staff grading with a non-draft location {0}. " + "Ensure that the location is valid.").format(location)) return False