Merge pull request #24540 from edx/aj/bug-fix-capa-ec
bug: fix an edge case in capa problem tolerance
This commit is contained in:
@@ -1551,7 +1551,7 @@ class NumericalResponse(LoncapaResponse):
|
|||||||
id=xml.get('id')
|
id=xml.get('id')
|
||||||
)
|
)
|
||||||
if tolerance_xml: # If it isn't an empty list...
|
if tolerance_xml: # If it isn't an empty list...
|
||||||
self.tolerance = contextualize_text(tolerance_xml[0], context)
|
self.tolerance = contextualize_text(tolerance_xml[0].strip(), context)
|
||||||
|
|
||||||
def get_staff_ans(self, answer):
|
def get_staff_ans(self, answer):
|
||||||
"""
|
"""
|
||||||
@@ -3057,7 +3057,7 @@ class FormulaResponse(LoncapaResponse):
|
|||||||
id=xml.get('id')
|
id=xml.get('id')
|
||||||
)
|
)
|
||||||
if tolerance_xml: # If it isn't an empty list...
|
if tolerance_xml: # If it isn't an empty list...
|
||||||
self.tolerance = contextualize_text(tolerance_xml[0], context)
|
self.tolerance = contextualize_text(tolerance_xml[0].strip(), context)
|
||||||
|
|
||||||
types = xml.get('type')
|
types = xml.get('type')
|
||||||
if types is None:
|
if types is None:
|
||||||
|
|||||||
@@ -1515,6 +1515,15 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docs
|
|||||||
incorrect_responses = ["", "3.01", "-1.01"]
|
incorrect_responses = ["", "3.01", "-1.01"]
|
||||||
self.assert_multiple_grade(problem, correct_responses, incorrect_responses)
|
self.assert_multiple_grade(problem, correct_responses, incorrect_responses)
|
||||||
|
|
||||||
|
def test_grade_percent_tolerance_with_spaces(self):
|
||||||
|
"""
|
||||||
|
Tests that system does not throw an error when tolerance data contains spaces before or after.
|
||||||
|
"""
|
||||||
|
problem = self.build_problem(answer=4, tolerance="10% ")
|
||||||
|
correct_responses = ["4.0", "4.00", "4.39", "3.61"]
|
||||||
|
incorrect_responses = ["", "4.41", "3.59", "0"]
|
||||||
|
self.assert_multiple_grade(problem, correct_responses, incorrect_responses)
|
||||||
|
|
||||||
def test_floats(self):
|
def test_floats(self):
|
||||||
"""
|
"""
|
||||||
Default tolerance for all responsetypes is 1e-3%.
|
Default tolerance for all responsetypes is 1e-3%.
|
||||||
|
|||||||
@@ -1214,12 +1214,15 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
|
|||||||
|
|
||||||
# Too late. Cannot submit
|
# Too late. Cannot submit
|
||||||
if self.closed():
|
if self.closed():
|
||||||
problem_location = text_type(self.location)
|
log.error(
|
||||||
if 'HarvardX+MCB80.1x+3T2019' in problem_location:
|
'ProblemClosedError: Problem %s, close date: %s, due:%s, attempts: %s/%s, is_past_due: %s',
|
||||||
log.info(
|
text_type(self.location),
|
||||||
'Problem %s closed, close date: %s, attempts: %s/%s, is_past_due: %s',
|
self.close_date,
|
||||||
problem_location, self.close_date, self.attempts, self.max_attempts, self.is_past_due()
|
self.due,
|
||||||
)
|
self.is_past_due(),
|
||||||
|
self.attempts,
|
||||||
|
self.max_attempts,
|
||||||
|
)
|
||||||
event_info['failure'] = 'closed'
|
event_info['failure'] = 'closed'
|
||||||
self.track_function_unmask('problem_check_fail', event_info)
|
self.track_function_unmask('problem_check_fail', event_info)
|
||||||
raise NotFoundError(_("Problem is closed."))
|
raise NotFoundError(_("Problem is closed."))
|
||||||
|
|||||||
Reference in New Issue
Block a user