-
Notifications
You must be signed in to change notification settings - Fork 168
Group flagged textanswers by question #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3141,51 +3141,65 @@ def test_textanswers_showing_up(self): | |
|
|
||
|
|
||
| class TestSemesterFlaggedTextAnswersView(WebTestStaffMode): | ||
| def test_correct_answers_show_up(self): | ||
| semester = baker.make(Semester) | ||
| @classmethod | ||
| def setUpTestData(cls): | ||
| cls.semester = baker.make(Semester) | ||
|
|
||
| url = reverse("staff:semester_flagged_textanswers", args=[semester.pk]) | ||
| cls.url = reverse("staff:semester_flagged_textanswers", args=[cls.semester.pk]) | ||
|
|
||
| manager = make_manager() | ||
| student = baker.make(UserProfile) | ||
| evaluations = baker.make( | ||
| Evaluation, course__semester=semester, participants=[student], _quantity=3, _bulk_create=True | ||
| cls.manager = make_manager() | ||
| cls.student = baker.make(UserProfile) | ||
| cls.evaluations = baker.make( | ||
| Evaluation, course__semester=cls.semester, participants=[cls.student], _quantity=3, _bulk_create=True | ||
| ) | ||
| textanswers = [ | ||
| cls.textanswers = [ | ||
| [baker.make(TextAnswer, answer=f"Answer {i} {j}", contribution__evaluation=evaluation) for j in range(3)] | ||
| for i, evaluation in enumerate(evaluations) | ||
| for i, evaluation in enumerate(cls.evaluations) | ||
| ] | ||
|
|
||
| response = self.app.get(url, user=manager) | ||
| cls.flagged_ids = [(0, 0), (0, 1), (1, 0)] | ||
|
|
||
| def test_correct_answers_show_up(self): | ||
| response = self.app.get(self.url, user=self.manager) | ||
| self.assertContains(response, "There are no flagged textanswers") | ||
|
|
||
| flagged_ids = [(0, 0), (0, 1), (1, 0)] | ||
| expected_texts = [ | ||
| "Answer 0 0", | ||
| "Answer 0 1", | ||
| "Answer 1 0", | ||
| evaluations[0].full_name, | ||
| evaluations[1].full_name, | ||
| self.evaluations[0].full_name, | ||
| self.evaluations[1].full_name, | ||
| ] | ||
| unexpected_texts = [ | ||
| "There are no flagged textanswers", | ||
| "Answer 0 2", | ||
| "Answer 1 1", | ||
| "Answer 2 0", | ||
| evaluations[2].full_name, | ||
| self.evaluations[2].full_name, | ||
| ] | ||
|
|
||
| for i, j in flagged_ids: | ||
| textanswers[i][j].is_flagged = True | ||
| textanswers[i][j].save() | ||
| for i, j in self.flagged_ids: | ||
| self.textanswers[i][j].is_flagged = True | ||
| self.textanswers[i][j].save() | ||
|
|
||
| response = self.app.get(url, user=manager) | ||
| response = self.app.get(self.url, user=self.manager) | ||
|
|
||
| for text in expected_texts: | ||
| self.assertContains(response, text) | ||
| for text in unexpected_texts: | ||
| self.assertNotContains(response, text) | ||
|
|
||
| def test_answer_grouping_and_question_order(self): | ||
| for i, j in self.flagged_ids: | ||
| self.textanswers[i][j].is_flagged = True | ||
| self.textanswers[i][j].save() | ||
|
|
||
| response = self.app.get(self.url, user=self.manager).body.decode() | ||
| for row in self.textanswers: | ||
| for textanswer in row: | ||
|
Comment on lines
+3198
to
+3199
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also thought about that, but was too tired to think about it. I'll see if something breaks, when I change it. |
||
| if textanswer.is_flagged: | ||
| self.assertLess(response.index(textanswer.question.text), response.index(textanswer.answer)) | ||
|
|
||
|
|
||
| class TestQuestionnaireNewVersionView(WebTestStaffMode): | ||
| @classmethod | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_correct_answers_show_upchecks first if there aren't any flagged textanswers, thats why I kept it duplicated