diff --git a/common/lib/xmodule/xmodule/capa_base.py b/common/lib/xmodule/xmodule/capa_base.py index 97abc3b4e9..97e9a665fc 100644 --- a/common/lib/xmodule/xmodule/capa_base.py +++ b/common/lib/xmodule/xmodule/capa_base.py @@ -1216,7 +1216,9 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): } try: - self.lcp.context['attempt'] = self.attempts + 1 + # expose the attempt number to the python custom grader + # self.lcp.context['attempt'] is 1 based, but the self.attempts is 0 based + self.lcp.context['attempt'] = self.attempts + 1 correct_map = self.lcp.grade_answers(answers) self.attempts = self.attempts + 1 self.lcp.done = True diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 15cb781cf7..f5930f078b 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -1116,7 +1116,8 @@ class CapaModuleTest(unittest.TestCase): self.assertEqual(result['success'], 'incorrect') self.assertEqual(module.get_score(), (0, 1)) self.assertEqual(module.correct_map[answer_id]['correctness'], 'incorrect') - # Expect that the number of attempts is incremented, still same attempt + + # Expect that the number of attempts is not incremented self.assertEqual(module.attempts, 1) self.assertEqual(module.lcp.context['attempt'], 1)