From 2653e9634a78fd21483949a36e5f09af8bb2129f Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 29 Jan 2014 14:24:24 +0200 Subject: [PATCH 1/2] Should not raise exception on empty answer. --- common/lib/capa/capa/responsetypes.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index dc0fbfeede..4b06369599 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -949,8 +949,6 @@ class NumericalResponse(LoncapaResponse): if self.range_tolerance: if isinstance(student_float, complex): raise StudentInputError(_(u"You may not use complex numbers in range tolerance problems")) - if isnan(student_float): - raise general_exception boundaries = [] for inclusion, answer in zip(self.inclusion, self.answer_range): boundary = self.get_staff_ans(answer) From 9876c993c5b0159b3108969515176a485fc7626c Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 29 Jan 2014 14:46:33 +0200 Subject: [PATCH 2/2] Fix test for isnan student answer. --- common/lib/capa/capa/tests/test_responsetypes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index 6d2b57d65d..3a3a5c3451 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -649,7 +649,7 @@ class StringResponseTest(ResponseTest): def test_case_sensitive(self): # Test single answer problem_specified = self.build_problem(answer="Second", case_sensitive=True) - + # should also be case_sensitive if case sensitivity is not specified problem_not_specified = self.build_problem(answer="Second") problems = [problem_specified, problem_not_specified] @@ -1105,11 +1105,13 @@ class NumericalResponseTest(ResponseTest): with self.assertRaises(StudentInputError): problem.grade_answers(input_dict) - # test isnan variable + # test isnan student input: no exception, + # but problem should be graded as incorrect problem = self.build_problem(answer='(1, 5)') input_dict = {'1_2_1': ''} - with self.assertRaises(StudentInputError): - problem.grade_answers(input_dict) + correct_map = problem.grade_answers(input_dict) + correctness = correct_map.get_correctness('1_2_1') + self.assertEqual(correctness, 'incorrect') # test invalid range tolerance answer with self.assertRaises(StudentInputError):