Commit 30c84118 by Adam Committed by GitHub

Merge pull request #14179 from edx/adam/fix-stringresponse-issue

Revert "tnl-4141 only whitespaces not allowed in answer and fixed the…
parents dec4034b c4c5a8e8
...@@ -190,10 +190,7 @@ class LoncapaResponse(object): ...@@ -190,10 +190,7 @@ class LoncapaResponse(object):
raise LoncapaProblemError(msg) raise LoncapaProblemError(msg)
for prop in self.required_attributes: for prop in self.required_attributes:
prop_value = xml.get(prop) if not xml.get(prop):
if prop_value: # Stripping off the empty strings
prop_value = prop_value.strip()
if not prop_value:
msg = "Error in problem specification: %s missing required attribute %s" % ( msg = "Error in problem specification: %s missing required attribute %s" % (
unicode(self), prop) unicode(self), prop)
msg += "\nSee XML source line %s" % getattr( msg += "\nSee XML source line %s" % getattr(
......
...@@ -974,12 +974,12 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring ...@@ -974,12 +974,12 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring
hint = correct_map.get_hint('1_2_1') hint = correct_map.get_hint('1_2_1')
self.assertEqual(hint, self._get_random_number_result(problem.seed)) self.assertEqual(hint, self._get_random_number_result(problem.seed))
def test_empty_answer_problem_creation_not_allowed(self): def test_empty_answer_graded_as_incorrect(self):
""" """
Tests that empty answer string is not allowed to create a problem Tests that problem should be graded incorrect if blank space is chosen as answer
""" """
with self.assertRaises(LoncapaProblemError): problem = self.build_problem(answer=" ", case_sensitive=False, regexp=True)
self.build_problem(answer=" ", case_sensitive=False, regexp=True) self.assert_grade(problem, u" ", "incorrect")
class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment