Commit 95eccf6e by Peter Fogg

Fix TrueFalse responses with single answers.

parent f4e38626
......@@ -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')
......
......@@ -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
......
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