diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index cac18d88cd..b98646bb02 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1323,9 +1323,11 @@ class TrueFalseResponse(MultipleChoiceResponse): def get_score(self, student_answers): correct = set(self.correct_choices) - answers = set(student_answers.get(self.answer_id, [])) + answers = student_answers.get(self.answer_id, []) + if not isinstance(answers, list): + answers = [answers] - if correct == answers: + if correct == set(answers): return CorrectMap(self.answer_id, 'correct') return CorrectMap(self.answer_id, 'incorrect') diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index eeba76e0de..751d6c08d6 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -151,6 +151,11 @@ class TrueFalseResponseTest(ResponseTest): self.assert_grade(problem, 'choice_foil_4', 'incorrect') self.assert_grade(problem, 'not_a_choice', 'incorrect') + def test_single_correct_response(self): + problem = self.build_problem(choices=[True, False]) + self.assert_grade(problem, 'choice_0', 'correct') + self.assert_grade(problem, ['choice_0'], 'correct') + class ImageResponseTest(ResponseTest): xml_factory_class = ImageResponseXMLFactory