Skip to content
Snippets Groups Projects
Commit 3787dcd7 authored by DawoudSheraz's avatar DawoudSheraz
Browse files

added conditional logs for RCA

parent 7f4af7ee
Branches
Tags release-2020-08-27-11.22
No related merge requests found
...@@ -736,7 +736,8 @@ class LoncapaProblem(object): ...@@ -736,7 +736,8 @@ class LoncapaProblem(object):
self.do_targeted_feedback(self.tree) self.do_targeted_feedback(self.tree)
html = contextualize_text( html = contextualize_text(
etree.tostring(self._extract_html(self.tree)).decode('utf-8'), etree.tostring(self._extract_html(self.tree)).decode('utf-8'),
self.context self.context,
six.text_type(self.capa_module.location)
) )
return html return html
......
...@@ -98,7 +98,7 @@ def compare_with_tolerance(student_complex, instructor_complex, tolerance=defaul ...@@ -98,7 +98,7 @@ def compare_with_tolerance(student_complex, instructor_complex, tolerance=defaul
return abs(student_complex - instructor_complex) <= tolerance return abs(student_complex - instructor_complex) <= tolerance
def contextualize_text(text, context): # private def contextualize_text(text, context, problem_location=None): # private
""" """
Takes a string with variables. E.g. $a+$b. Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context Does a substitution of those variables from the context
...@@ -115,17 +115,26 @@ def contextualize_text(text, context): # private ...@@ -115,17 +115,26 @@ def contextualize_text(text, context): # private
try: try:
data_string = data_string.replace(old_value, new_value) data_string = data_string.replace(old_value, new_value)
return data_string return data_string
except Exception as error: except Exception: # pylint: disable=broad-except
log.exception( if problem_location and problem_location == 'block-v1:MITx+CTL.SC3x+2T2019+type@problem+block@cb29c9209862423d87bef76c4ef15695': # pylint: disable=line-too-long
u'ContextualizeTextError: text(%s): %s, context_key(%s): %s, context_value(%s): %s, Error: %s', log.error(
type(text), u'ContextualizeTextError: data_string(%s), old_value(%s), new_value(%s)',
text, type(data_string),
type(context_key), type(old_value),
context_key, type(new_value),
type(context_value), )
context_value, log.error(
six.text_type(error) u'ContextualizeTextError: data_string: %s',
) data_string,
)
log.error(
u'ContextualizeTextError: new_value : %s',
new_value,
)
log.error(
u'ContextualizeTextError: old_value: %s',
old_value,
)
raise raise
if not text: if not text:
......
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