From 573116073ebfee835c582ba10bcbb5c6566ef975 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Tue, 30 Apr 2013 11:16:14 -0400 Subject: [PATCH] Add error message when factorial given non-integral value --- common/lib/capa/capa/responsetypes.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 5b1b46d858..3301731929 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1851,6 +1851,13 @@ class FormulaResponse(LoncapaResponse): 'formularesponse: undefined variable in given=%s' % given) raise StudentInputError( "Invalid input: " + uv.message + " not permitted in answer") + except ValueError as ve: + # This is thrown when fact() or factorial() is used in a formularesponse answer + # that tests on negative and/or non-integer inputs + log.debug( + 'formularesponse: factorial function used in response that tests negative and/or non-integer inputs. given={0}'.format(given)) + raise StudentInputError( + "factorial function not permitted in answer for this problem. Provided answer was: {0}".format(given)) except Exception as err: # traceback.print_exc() log.debug('formularesponse: error %s in formula' % err)