fix TNL-767 When students click "check" without submitting an answer, our basic problem types respond in inconsistent ways.

This commit is contained in:
Ayub-Khan
2015-12-29 19:20:18 +05:00
parent e8925972d9
commit dce5bbc039
2 changed files with 11 additions and 0 deletions

View File

@@ -2134,6 +2134,10 @@ class StringResponse(LoncapaResponse):
Note: for old code, which supports _or_ separator, we add some backward compatibility handling.
Should be removed soon. When to remove it, is up to Lyla Fisher.
"""
# if given answer is empty.
if not given:
return False
_ = self.capa_system.i18n.ugettext
# backward compatibility, should be removed in future.
if self.backward:

View File

@@ -946,6 +946,13 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring
hint = correct_map.get_hint('1_2_1')
self.assertEqual(hint, self._get_random_number_result(problem.seed))
def test_empty_answer_graded_as_incorrect(self):
"""
Tests that problem should be graded incorrect if blank space is chosen as answer
"""
problem = self.build_problem(answer=" ", case_sensitive=False, regexp=True)
self.assert_grade(problem, u" ", "incorrect")
class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring
xml_factory_class = CodeResponseXMLFactory