Commit 185bac18 by Albert (AJ) St. Aubin Committed by GitHub

Merge pull request #15012 from edx/aj/EDUCATOR-60

Updated the message and style of the status notification when a user …
parents 8ce4e116 d9b8d51d
...@@ -1597,9 +1597,8 @@ class NumericalResponse(LoncapaResponse): ...@@ -1597,9 +1597,8 @@ 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"You may not use variables ({bad_variables}) in numerical problems.").format( _(u"Answers can include numerals, operation signs, and a few specific characters, "
bad_variables=undef_var.message, u"such as the constants e and i.")
)
) )
except ValueError as val_err: except ValueError as val_err:
if 'factorial' in val_err.message: if 'factorial' in val_err.message:
...@@ -1608,7 +1607,7 @@ class NumericalResponse(LoncapaResponse): ...@@ -1608,7 +1607,7 @@ class NumericalResponse(LoncapaResponse):
# ve.message will be: `factorial() only accepts integral values` or # ve.message will be: `factorial() only accepts integral values` or
# `factorial() not defined for negative values` # `factorial() not defined for negative values`
raise StudentInputError( raise StudentInputError(
_("factorial function evaluated outside its domain:" _("Factorial function evaluated outside its domain:"
"'{student_answer}'").format(student_answer=cgi.escape(student_answer)) "'{student_answer}'").format(student_answer=cgi.escape(student_answer))
) )
else: else:
...@@ -3104,7 +3103,8 @@ class FormulaResponse(LoncapaResponse): ...@@ -3104,7 +3103,8 @@ class FormulaResponse(LoncapaResponse):
cgi.escape(answer) cgi.escape(answer)
) )
raise StudentInputError( raise StudentInputError(
_("Invalid input: {bad_input} not permitted in answer.").format(bad_input=err.message) _(u"Answers can include numerals, operation signs, and a few specific characters, "
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:
...@@ -3119,7 +3119,7 @@ class FormulaResponse(LoncapaResponse): ...@@ -3119,7 +3119,7 @@ class FormulaResponse(LoncapaResponse):
cgi.escape(answer) cgi.escape(answer)
) )
raise StudentInputError( raise StudentInputError(
_("factorial function not permitted in answer " _("Factorial function not permitted in answer "
"for this problem. Provided answer was: " "for this problem. Provided answer was: "
"{bad_input}").format(bad_input=cgi.escape(answer)) "{bad_input}").format(bad_input=cgi.escape(answer))
) )
......
...@@ -1669,8 +1669,9 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring ...@@ -1669,8 +1669,9 @@ 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"), r"You may not use variables \(x\) in numerical problems"), (calc.UndefinedVariable("x"), "Answers can include numerals, operation signs, "
(ValueError("factorial() mess-up"), "factorial function evaluated outside its domain"), "and a few specific characters, such as the constants e and i."),
(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"),
(ZeroDivisionError(), "Could not interpret '.*' as a number") (ZeroDivisionError(), "Could not interpret '.*' as a number")
......
...@@ -1238,7 +1238,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): ...@@ -1238,7 +1238,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
# without a stack trace # without a stack trace
else: else:
# Translators: {msg} will be replaced with a problem's error message. # Translators: {msg} will be replaced with a problem's error message.
msg = _(u"Error: {msg}").format(msg=inst.message) msg = inst.message
return {'success': msg} return {'success': msg}
......
...@@ -1104,7 +1104,7 @@ div.problem { ...@@ -1104,7 +1104,7 @@ div.problem {
.notification-message { .notification-message {
display: inline-block; display: inline-block;
width: flex-grid(6,10); width: flex-grid(7,10);
// Make notification tall enough that when the "Review" button is displayed, // Make notification tall enough that when the "Review" button is displayed,
// the notification does not grow in height. // the notification does not grow in height.
margin-bottom: 8px; margin-bottom: 8px;
......
...@@ -821,7 +821,8 @@ class CapaModuleTest(unittest.TestCase): ...@@ -821,7 +821,8 @@ class CapaModuleTest(unittest.TestCase):
result = module.submit_problem(get_request_dict) result = module.submit_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
expected_msg = 'Error: test error' expected_msg = 'test error'
self.assertEqual(expected_msg, result['success']) self.assertEqual(expected_msg, result['success'])
# Expect that the number of attempts is NOT incremented # Expect that the number of attempts is NOT incremented
...@@ -889,7 +890,8 @@ class CapaModuleTest(unittest.TestCase): ...@@ -889,7 +890,8 @@ class CapaModuleTest(unittest.TestCase):
result = module.submit_problem(get_request_dict) result = module.submit_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
expected_msg = u'Error: ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ' expected_msg = u'ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ'
self.assertEqual(expected_msg, result['success']) self.assertEqual(expected_msg, result['success'])
# Expect that the number of attempts is NOT incremented # Expect that the number of attempts is NOT incremented
......
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