Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion evap/evaluation/management/commands/anonymize.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Contribution,
Course,
CourseType,
Evaluation,
Program,
RatingAnswerCounter,
Semester,
Expand Down Expand Up @@ -69,7 +70,7 @@ def anonymize_data(self):
self.anonymize_evaluations()
self.anonymize_questionnaires()
self.anonymize_answers(lorem_ipsum)

self.anonymize_staff_notes(lorem_ipsum)
self.stdout.write("")
self.stdout.write("Done.")

Expand Down Expand Up @@ -276,6 +277,13 @@ def anonymize_answers(self, lorem_ipsum):
finally:
self.stdout.ending = "\n"

def anonymize_staff_notes(self, lorem_ipsum):
self.stdout.write("Replacing text answers with fake ones...")
Comment thread
anjaton marked this conversation as resolved.
Outdated
for evaluation in Evaluation.objects.all():
if evaluation.staff_notes != "":
evaluation.staff_notes = self.lorem(evaluation.staff_notes, lorem_ipsum)
evaluation.save()

# Returns a string with the same number of lorem ipsum words as the given text
@staticmethod
def lorem(text, lorem_ipsum):
Expand Down
5 changes: 5 additions & 0 deletions evap/evaluation/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def setUpTestData(cls):
course=cls.course,
name_de="Wie man Software testet",
name_en="Testing your software",
staff_notes="This evaluation has dropout answers",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit of a misleading note because this is not the case in this test, can we use something else?

)
baker.make(
Evaluation,
Expand Down Expand Up @@ -180,6 +181,10 @@ def test_user_with_password(self):
with self.assertRaises(AssertionError):
management.call_command("anonymize", stdout=StringIO())

def test_staff_notes_are_anonymized(self):
management.call_command("anonymize", stdout=StringIO())
self.assertEqual(Evaluation.objects.get(id=self.evaluation.id).staff_notes, "Lorem ipsum dolor sit amet,")


class TestRefreshResultsCacheCommand(TestCase):
def test_calls_cache_results(self):
Expand Down