Group flagged textanswers by question - #2725
Conversation
| for i, j in self.flagged_ids: | ||
| self.textanswers[i][j].is_flagged = True | ||
| self.textanswers[i][j].save() |
There was a problem hiding this comment.
both tests now do this, I think it would make more sense to move this into the shared setup code (where we also define flagged_ids)
There was a problem hiding this comment.
test_correct_answers_show_up checks first if there aren't any flagged textanswers, thats why I kept it duplicated
| for row in self.textanswers: | ||
| for textanswer in row: |
There was a problem hiding this comment.
I may just be too tired, but is there any value in having the textanswers be stored in two levels of nested lists here, or could we flatten that to just a one-dimensional list?
There was a problem hiding this comment.
I also thought about that, but was too tired to think about it. I'll see if something breaks, when I change it.
|
@just-spafi do you want to keep working on this, or should we take over / assign this issue to someone else? |
I plan on finishing this in the next two weeks :) |
|
cool, no stress :) (quick heads up if you haven't heard, but tomorrow is one of the rare days on which we won't have a development meeting; we will meet again next week. of course, feel free to reach out on github at any other time too) |
flagged_textanswers = TextAnswer.objects.filter(
# is_flagged=True,
contribution__evaluation__course__semester=semester,
).order_by("contribution__evaluation", "assignment__questionnaire", "assignment__question")
my_textanswers = {
evaluation: {
questionnaire: list(answers)
for questionnaire, answers in itertools.groupby(evaluation_answers, key=lambda x: x.assignment.questionnaire)
}
for evaluation, evaluation_answers in itertools.groupby(flagged_textanswers, key=lambda x: x.contribution.evaluation)
}
for evaluation, questionnaires in my_textanswers.items():
print(evaluation)
for questionnaire, answers in questionnaires.items():
print(" ", questionnaire)
for answer in answers:
print(" ", answer.answer) |
Fixes #2711