Skip to content

Commit 4abbfed

Browse files
committed
Added warning for triple factorial
1 parent a07755d commit 4abbfed

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

app/evaluation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ def evaluation_function(response, answer, params, include_test_data=False) -> di
288288
if "!" in response:
289289
evaluation_result.add_feedback(("NOTATION_WARNING_FACTORIAL", symbolic_comparison_internal_messages("NOTATION_WARNING_FACTORIAL")(dict())))
290290

291+
if "!!!" in response:
292+
evaluation_result.add_feedback(
293+
("NOTATION_WARNING_TRIPLE_FACTORIAL", symbolic_comparison_internal_messages("NOTATION_WARNING_TRIPLE_FACTORIAL")(dict())))
294+
291295
reserved_expressions_success, reserved_expressions = parse_reserved_expressions(reserved_expressions_strings, parameters, evaluation_result)
292296
if reserved_expressions_success is False:
293297
return evaluation_result.serialise(include_test_data)

app/feedback/symbolic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"PARSE_ERROR": f"`{inputs.get('x','')}` could not be parsed as a valid mathematical expression. Ensure that correct codes for input symbols are used, correct notation is used, that the expression is unambiguous and that all parentheses are closed.",
2222
"NOTATION_WARNING_EXPONENT": "Note that `^` cannot be used to denote exponentiation, use `**` instead.",
2323
"NOTATION_WARNING_FACTORIAL": "Note that `!` cannot be used to denote factorial, use `factorial(...)` instead.",
24+
"NOTATION_WARNING_TRIPLE_FACTORIAL": "Note that `!!!` is not supported.",
2425
"EXPRESSION_NOT_EQUALITY": "The response was an expression but was expected to be an equality.",
2526
"EQUALITY_NOT_EXPRESSION": "The response was an equality but was expected to be an expression.",
2627
"EQUALITIES_EQUIVALENT": None,

app/tests/symbolic_evaluation_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,14 @@ def test_double_exclamation_mark_for_factorial(self, response, answer, value):
18991899
result = evaluation_function(response, answer, params)
19001900
assert result["is_correct"] is value
19011901

1902+
def test_warning_for_triple_factorial(self):
1903+
answer = '2^4!'
1904+
response = '2^4!!!'
1905+
params = {'strict_syntax': False}
1906+
result = evaluation_function(response, answer, params, include_test_data=True)
1907+
assert result["is_correct"] is False
1908+
assert "NOTATION_WARNING_TRIPLE_FACTORIAL" in result["tags"]
1909+
19021910
def test_alternatives_to_input_symbols_takes_priority_over_elementary_function_alternatives(self):
19031911
answer = "Ef*exp(x)"
19041912
params = {

0 commit comments

Comments
 (0)