Group flagged textanswers by question#2725
Conversation
| is_flagged=True, | ||
| contribution__evaluation__course__semester=semester, | ||
| ).order_by("contribution__evaluation") | ||
| ).order_by("contribution__evaluation", "assignment__questionnaire", "assignment__question") |
There was a problem hiding this comment.
The problem with ordering in one place and using regroup in a totally separate place is always that we may change one and forget about the other.
Could just use unordered_groupby here and pass a grouped collection into the template? Then we don't have that issue
| 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)
| 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.
Fixes #2711