Fix TrueFalse responses with single answers.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user