Commit eadc0995 by Christina Roberts Committed by GitHub

Merge pull request #15597 from edx/christina/revert-ed-60

Restore more specific error messages.
parents 9cf2d7ea 4e3ed8b5
...@@ -1602,8 +1602,9 @@ class NumericalResponse(LoncapaResponse): ...@@ -1602,8 +1602,9 @@ class NumericalResponse(LoncapaResponse):
student_float = evaluator({}, {}, student_answer) student_float = evaluator({}, {}, student_answer)
except UndefinedVariable as undef_var: except UndefinedVariable as undef_var:
raise StudentInputError( raise StudentInputError(
_(u"Answers can include numerals, operation signs, and a few specific characters, " _(u"You may not use variables ({bad_variables}) in numerical problems.").format(
u"such as the constants e and i.") bad_variables=undef_var.message,
)
) )
except ValueError as val_err: except ValueError as val_err:
if 'factorial' in val_err.message: if 'factorial' in val_err.message:
...@@ -3108,8 +3109,7 @@ class FormulaResponse(LoncapaResponse): ...@@ -3108,8 +3109,7 @@ class FormulaResponse(LoncapaResponse):
cgi.escape(answer) cgi.escape(answer)
) )
raise StudentInputError( raise StudentInputError(
_(u"Answers can include numerals, operation signs, and a few specific characters, " _("Invalid input: {bad_input} not permitted in answer.").format(bad_input=err.message)
u"such as the constants e and i.")
) )
except ValueError as err: except ValueError as err:
if 'factorial' in err.message: if 'factorial' in err.message:
......
...@@ -1669,8 +1669,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring ...@@ -1669,8 +1669,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring
problem = self.build_problem(answer=4) problem = self.build_problem(answer=4)
errors = [ # (exception raised, message to student) errors = [ # (exception raised, message to student)
(calc.UndefinedVariable("x"), "Answers can include numerals, operation signs, " (calc.UndefinedVariable("x"), r"You may not use variables \(x\) in numerical problems"),
"and a few specific characters, such as the constants e and i."),
(ValueError("factorial() mess-up"), "Factorial function evaluated outside its domain"), (ValueError("factorial() mess-up"), "Factorial function evaluated outside its domain"),
(ValueError(), "Could not interpret '.*' as a number"), (ValueError(), "Could not interpret '.*' as a number"),
(pyparsing.ParseException("oopsie"), "Invalid math syntax"), (pyparsing.ParseException("oopsie"), "Invalid math syntax"),
......
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