From ddb373b6e1ac45295d5074d3c6d9e85bd9df467a Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Fri, 10 Aug 2018 11:08:30 +0200 Subject: [PATCH] Fixed bug in anonymisation function The function `do_anonymous` in `hektor.py` was dependant upon the iteration order of a dictionary being the same as the insertion order. This is an implementation detail of CPython3.6 and should not be relied upon. --- hektor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hektor.py b/hektor.py index 4d1a540..39ed0c0 100644 --- a/hektor.py +++ b/hektor.py @@ -227,11 +227,11 @@ def do_anonymous(students: Dict[str, Union[str, List]]): reverser = {get_random_xkcd_identifier(): s for s in students} students_anonymous = [{ 'fullname': ' '.join(w[0].capitalize() + w[1:] - for w in r.split(DELIMITER)), - 'identifier': r, - 'username': r, + for w in pseudo_identifier.split(DELIMITER)), + 'identifier': pseudo_identifier, + 'username': pseudo_identifier, 'submissions': student['submissions'] - } for r, student in zip(reverser, students)] + } for pseudo_identifier, student in reverser.items()] with open(args.personal_secret_table, 'w') as out: print('key;previous identifier;fullname', file=out) -- GitLab