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