diff --git a/common/lib/capa/capa/correctmap.py b/common/lib/capa/capa/correctmap.py index feea917ded..9e76fc20bf 100644 --- a/common/lib/capa/capa/correctmap.py +++ b/common/lib/capa/capa/correctmap.py @@ -117,7 +117,7 @@ class CorrectMap(object): Otherwise, return 0 points """ if self.is_correct(answer_id): npoints = self.get_property(answer_id, 'npoints') - return npoints if npoints else 1 + return npoints if npoints is not None else 1 else: return 0 diff --git a/common/lib/capa/capa/tests/test_correctmap.py b/common/lib/capa/capa/tests/test_correctmap.py index ed0e9a1948..23734467bb 100644 --- a/common/lib/capa/capa/tests/test_correctmap.py +++ b/common/lib/capa/capa/tests/test_correctmap.py @@ -69,6 +69,7 @@ class CorrectMapTest(unittest.TestCase): # 2) correct, None points # 3) incorrect, 5 points # 4) incorrect, None points + # 5) correct, 0 points self.cmap.set(answer_id='1_2_1', correctness='correct', npoints=5) @@ -85,6 +86,10 @@ class CorrectMapTest(unittest.TestCase): correctness='incorrect', npoints=None) + self.cmap.set(answer_id='5_2_1', + correctness='correct', + npoints=0) + # Assert that we get the expected points # If points assigned and correct --> npoints # If no points assigned and correct --> 1 point @@ -93,6 +98,7 @@ class CorrectMapTest(unittest.TestCase): self.assertEqual(self.cmap.get_npoints('2_2_1'), 1) self.assertEqual(self.cmap.get_npoints('3_2_1'), 0) self.assertEqual(self.cmap.get_npoints('4_2_1'), 0) + self.assertEqual(self.cmap.get_npoints('5_2_1'), 0) def test_set_overall_message(self):