Commit 392de8d4 by Ned Batchelder

Check functions need access to course-local code also, so we need to save the…

Check functions need access to course-local code also, so we need to save the python path from the problem setup, and use it for the check function.
parent 073c6d9a
......@@ -475,12 +475,11 @@ class LoncapaProblem(object):
msg = "Error while executing script code: %s" % str(err).replace('<', '&lt;')
raise responsetypes.LoncapaProblemError(msg)
# store code source in context
# Store code source in context, along with the Python path needed to run it correctly.
context['script_code'] = all_code
context['python_path'] = python_path
return context
def _extract_html(self, problemtree): # private
'''
Main (private) function which converts Problem XML tree to HTML.
......
......@@ -286,7 +286,7 @@ class LoncapaResponse(object):
}
try:
safe_exec.safe_exec(code, globals_dict)
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'])
except Exception as err:
msg = 'Error %s in evaluating hint function %s' % (err, hintfn)
msg += "\nSee XML source line %s" % getattr(
......@@ -972,7 +972,7 @@ class CustomResponse(LoncapaResponse):
'ans': ans,
}
globals_dict.update(kwargs)
safe_exec.safe_exec(code, globals_dict, cache=self.system.cache)
safe_exec.safe_exec(code, globals_dict, python_path=self.context['python_path'])
return globals_dict['cfn_return']
return check_function
......
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