Commit 66655080 by Vik Paruchuri

Log a warning if assumption about path is not correct.

parent 9e181304
from xmodule.modulestore import search from xmodule.modulestore import search
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem from xmodule.modulestore.exceptions import ItemNotFoundError, NoPathToItem
import logging
log = logging.getLogger(__name__)
def does_location_exist(course_id, location): def does_location_exist(course_id, location):
""" """
...@@ -12,8 +15,13 @@ 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) search.path_to_location(modulestore(), course_id, location)
return True return True
except ItemNotFoundError: 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 return False
except NoPathToItem: 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 return False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment