Reputation: 2699
I am grading multiple choice questions which have multiple correct answers. You only get a point if you get all the correct answers and non of the incorrect ones.
elif response.question.type == 'checkbox':
all_correct = False
my_answers = Answer.objects.filter(pk__in=response.answer)
correct_answers = Answer.objects.filter(question=response.question, correct=True)
// Can I just do this?
if my_answers == correct_answers:
all_correct = True
if all_correct:
total_correct += 1
Upvotes: 1
Views: 174
Reputation: 5194
convert query sets to list, and do comparison.
query sets should have same sort order
if list(my_answers) == list(correct_answers):
Upvotes: 1